Reputation: 5177
Is there a way that when we use ft.addToBackStack(null);
we only add a single instance to the BackStack? Adding multiple instances of the same fragment to the Back Stack creates a clutter when the user presses the Back Button?
Upvotes: 5
Views: 3672
Reputation: 51
You could try setting a string to the addToBackStack method. Ex
ft.addToBackStack("fragmentA");
Later then, if you are coing to insert that same fragment again. You do this before adding it to the layout.
getFragmentManager().popBackStack("fragmentA", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Upvotes: 3