There is an Activity with 5 fragments (wizard).
StartFrag -(start)-> Frag1 -(next)-> Frag2 -(next)-> SubmitFrag
-(submit)-> SuccessFrag.
After Taping SubmitMore button on Success fragment, I want to remove Frag1, Frag2 and SubmitFrag from backstage and return to StartFrag. How to do that?
You could try this
FragmentManager fm = getFragmentManager();
int count = fm.getBackStackEntryCount();
for(int i = 0; i < count; ++i) {
fm.popBackStack();
}
试试这个
mFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
You could try this
FragmentManager fm = getFragmentManager();
FragmentTransaction ft=fm.beginTransaction();
ft.add(R.id.group,startFrag,"");
ft.addtoBackStack("startFrag");
ft.commit();
enter code here
// add other 4 fragments here
when you want to go startFrag on click of some button you can try below code.
fm.popBackStack("startFrag",0);
//where startFrag is the tag which you specify when you called
//addtoBackStack("startFrag")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.