0
如何在一個動作中添加一個片段並在Android中釋放所有的背堆棧?在Android中的一個動作中添加一個片段並釋放背堆棧片段
我已經試過:
getSupportFragmentManager().popBackStack(null,FragmentManager.POP_BACK_STACK_INCLUSIVE);
然後加入我的新片段:
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left);
fragmentTransaction.replace(R.id.content_frame, fragment);
fragmentTransaction.commitAllowingStateLoss();
// or
fragmentTransaction.commit(); // i tried both of them
,但我得到:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState