marioosh
marioosh

Reputation: 28556

How to replace last element of back stack?

How to add fragment to back stack, but replacing last history ? Example below.

[frag1].addToBackStack(null) 
     -> [frag2].addToBackStack(null) 
         -> [frag3].addToBackStack(null) // need here replace frag2 in history (back button get to frag1)

Upvotes: 1

Views: 697

Answers (1)

You can use getFragmentManager().popBackStack(); to remove frag2 to the backstack and getFragmentManager().beginTransaction().replace(...) to change the frag3 by other.

Hope it helps you!

Upvotes: 2

Related Questions