In my app, i have 4 buttons, these buttons will create and replace fragment then added it to the backstack.
So for example :
[A] -> [B] -> [C] -> [D]
First fragment A
is exist, when i click at button B
, fragment A
will be replaced with fragment B
and added fragment B
to the backstack, when i click at button C
, fragment B
will be replaced with fragment C
and added fragment C
to the backstack, and so on.
My question is, when button A
is clicked again, it will removes fragment A
from previous backstack and added it to the last stack, so the image will looks like this:
[B] -> [C] -> [D] -> [A]
Or if i click at button B
, the image will looks like this:
[A] -> [C] -> [D] -> [B]
How do i do it? i have try using FragmentManager.popBackStack(indexStack, 0)
, FragmentManager.popBackStack(Tag, 0)
but none of these work.