I'm On the 4th fragment. On 4th fragment view when i click on cancel button it goes on 2nd fragment. but i use popBackStackImmediate it goes on 3rd fragment.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
fmgr.popBackStackImmediate(2, 0);
or
fmgr.popBackStackImmediate(3, FragmentManager.POP_BACK_STACK_INCLUSIVE);
should do the trick
You can also name your fragment in your transaction
fmgr.beginTransaction()
.add(R.id.container, FRAGMENT, "your_fragment")
.addToBackStack("your_fragment")
.commitAllowingStateLoss();
fmgr.executePendingTransactions();
And then pop to this fragment:
fmgr.popBackStackImmediate("your_fragment", 0);