nilkash
nilkash

Reputation: 7536

Remove all fragments up to particular fragment in stack android

Hi I am developing android application in which I am using fragments and push to back stack. So my scenario is like this I have fragment A, B, C, D and I push them in following sequence A-->B-->C-->D and what I want I want to remove D and C and bring B on top. Is there any way to remove all together and bring one particular fragment on top of the stack. like pop from back stack upto xyz fragment tag. Is there any way to do this. Need help thank you.

Upvotes: 1

Views: 1540

Answers (1)

Karakuri
Karakuri

Reputation: 38595

You want this: FragmentManager.popBackStack(int id, int flags)

You need to save the value returned by FragmentTransaction.commit() of the transaction that adds Fragment B. Then later call getFragmentManager().popBackStack(commitId, 0);

Upvotes: 4

Related Questions