popBackStackImmediate from 4th fragment to the 2nd fragment?
10,460
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);
Author by
Kailas
#SOreadytohelp I Like study the new technology. I'm worked on PHP, Android and .Net
Updated on June 30, 2022Comments
-
Kailas almost 2 years
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.
-
Kailas over 9 yearsThis fmgr.popBackStackImmediate(3, FragmentManager.POP_BACK_STACK_INCLUSIVE); line perfectly worked me. Thank you so much.