我想在关闭活动时更改Fragment。我试图进入活动,FragmentTransaction但它不是正确的方法。我能怎么做?谢谢
Fragment newFragment = new Ele_Fragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.frame_container, newFragment);
transaction.addToBackStack(null);
// Commit the transaction
transaction.commit();
答案 0 :(得分:0)
尝试将标记添加到addToBackStack而不是传递null
.addToBackStack(Ele_Fragment.TAG);
通过这种方式你可以勾选你传递的片段。