How to delete a specific fragment from back stack in android

后端 未结 6 788
野趣味
野趣味 2020-12-29 05:09

I have a problem about removing a specific fragment from back stack.My scenario is like this.Fragment-1 is replaced with Fragment-2 and then Fragment-2 is replaced with Frag

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 05:39

       for (int i = 0; i < mFragmentManager.getBackStackEntryCount(); i++) {
            currentFragment = mFragmentManager.getFragments().get(i);
            if (!(currentFragment instanceof ParticularFragment))
                mFragmentManager.popBackStack();
            else
                break;
        }
    

提交回复
热议问题