Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

popBackStackImmediate from 4th fragment to the 2nd fragment?

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.

like image 583
Kailas Avatar asked Jan 22 '26 03:01

Kailas


1 Answers

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);
like image 196
vbonnet Avatar answered Jan 24 '26 10:01

vbonnet