gpt4 book ai didi

android - 异常 java.lang.IllegalStateException : Can not perform this action after onSaveInstanceState

转载 作者:行者123 更新时间:2023-11-29 19:09:41 33 4
gpt4 key购买 nike

异常 java.lang.IllegalStateException:在 onSaveInstanceState 之后无法执行此操作

android.support.v4.app.FragmentManagerImpl.checkStateLoss (FragmentManager.java:1842) android.support.v4.app.FragmentManagerImpl.enqueueAction (FragmentManager.java:1860) android.support.v4.app.BackStackRecord.commitInternal (BackStackRecord.java:650) android.support.v4.app.BackStackRecord.commit (BackStackRecord.java:609) > com.bharat.example.adapter.Articles_Adapter$MyViewHolder.onClick (Articles_Adapter.java:147)

android.view.View.performClick (View.java:5201) android.view.View$PerformClick.run (View.java:21163) android.os.Handler.handleCallback (Handler.java:746) android.os.Handler.dispatchMessage (Handler.java:95) android.os.Looper.loop (Looper.java:148) android.app.ActivityThread.main (ActivityThread.java:5443) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:728) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)

崩溃发生在 FragmentTransaction commit() 时。

FragmentTransaction transaction = ((Content_Activity) main).getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.left_in, R.anim.left_out, R.anim.right_in, R.anim.right_out);
transaction.replace(R.id.fragment_frame, fragment, "web");
transaction.addToBackStack("home");
transaction.commit();

使用 android.support.v4.app.FragmentTransaction

最佳答案

添加这一行。它对我来说工作正常。

transaction.commitAllowingStateLoss()

关于android - 异常 java.lang.IllegalStateException : Can not perform this action after onSaveInstanceState,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45809011/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com