关闭ActivityDialog时Android更改片段

时间:2014-07-13 17:42:59

标签: android android-activity view fragment

我想在关闭活动时更改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();

1 个答案:

答案 0 :(得分:0)

尝试将标记添加到addToBackStack而不是传递null

.addToBackStack(Ele_Fragment.TAG);

通过这种方式你可以勾选你传递的片段。