这篇文章上次修改于 1985 天前,可能其部分内容已经发生变化,如有疑问可询问作者。 >这个是因为没有设置动画,但是设置了transaction导致,按下面改动代码 改动前: ```java supportFragmentManager .beginTransaction() .replace(R.id.content, fragment) .addToBackStack(fragment.toString()) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) .commit() ``` 改动后 ```java supportFragmentManager .beginTransaction() .replace(R.id.content, fragment) .addToBackStack(fragment.toString()) //.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) //注释掉 .commit() ``` ```bash E/FragmentManager: No field with the name mListener is found in Animation class java.lang.NoSuchFieldException: No field mListener in class Landroid/view/animation/Animation; (declaration of 'android.view.animation.Animation' appears in /system/framework/framework.jar!classes3.dex) at java.lang.Class.getDeclaredField(Native Method) at androidx.fragment.app.FragmentManagerImpl.getAnimationListener(FragmentManager.java:1301) at androidx.fragment.app.FragmentManagerImpl.setHWLayerAnimListenerIfAlpha(FragmentManager.java:1283) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1811) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802) at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273) at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229) at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201) at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620) at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1425) at android.app.Activity.performStart(Activity.java:7806) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3284) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7319) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934) ```
没有评论