错误:
java.lang.NullPointerException
11-15 09:04:21.023: E/AndroidRuntime(4057): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:591)
11-15 09:04:21.023: E/AndroidRuntime(4057): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416
执行代码:
if (mCurTransaction != null) {
mCurTransaction.commitAllowingStateLoss();
// if (manager != null)
// manager.executePendingTransactions();
原因:当FragmentManager add,attach,remove,dettach时如果fragment为null,如add(null)
则容易mCurTransaction.commitAllowingStateLoss() 方法可能出现这个错误。
解决方法:在执行这些方法时判断fragment是否为null。 如if(fragment != null) add(fragment);