【发布时间】:2018-03-28 08:24:57
【问题描述】:
java.lang.IllegalStateException: FragmentManager is already executing transactions
我已阅读有关此的所有 StackOverflow 问题,但没有任何帮助。 只是想分享我的经验
public void onResume() {
super.onResume()
if(condition) replaceFragment()
}
public void replaceFragment() {
if (fragmentName != null && !this.isDestroyed()) {
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(container_id, FragmentInstantiate());
ft.commitAllowingStateLoss();
}
}
是 commit()/commitAllowingStateLoss() 导致了 IllegalStateException: FragmentManager 已经在执行事务。不是 commitNow() 或 executePendingTransactions()
【问题讨论】:
标签: android android-fragments fragmentmanager