我有三个片段 a , b , c
我用主要活动替换了
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.add(R.id.fram_container, new Fragment1(), "tag1");
transaction.commit();
a 到 b
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.replace(R.id.fram_container, new Fragment2(), "tag2");
transaction.commit();
和 b 到 c
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.replace(R.id.fram_container, new Fragment3(), "tag3");
transaction.commit();
c ... 中的
我希望 c 重新按下 a 重定向,而不会在 c 中执行任何操作 我想在后面按 b 。
我能做什么以及如何做?
答案 0 :(得分:2)
按
重新实施以下代码public void backToFragment(final Fragment fragment) {
// go back to something that was added to the backstack
getSupportFragmentManager().popBackStackImmediate(
fragment.getClass().getName(), 0);
// use 0 or the below constant as flag parameter
// FragmentManager.POP_BACK_STACK_INCLUSIVE);
}