In addition to popBackStack()
and popBackStackImmediate()
, is there any other way to specify to close the fragment in the manager?
Using fragment
to manage the interface, I encountered a problem.
I opened interface B from interface A, and then interface B opened interface C. At this time, I need to return directly from interface C to A. interface,
At the beginning, I tried to popBackStack()
when opening interface C, but an exception was thrown
. . It suddenly occurred to me while typing that I could use popBackStack(A's Tag, 0) to directly remove B and C. But I still want to ask if there are other ways to manage them?
I also want to ask popBackStackImmediate()
Is it possible that it will not be executed?
manager.popBackStackImmediate(tag, 1);//不会被执行?
manager.popBackStack(tag, 1); //会被执行?
天蓬老师2017-05-16 13:37:12
The questioner did not read the API documentation carefully. Before reading the documentation, install Google Translate
popBackStack()
这样的函数都是跟后退栈有关的调用, Fragment
You don’t need to push to the back stack. If you need to respond to the back button, you need to manage the Fragment’s back stack.
You can refer to how the following classes manage Fragments:
FragmentPagerAdapter
FragmentStatePagerAdapter
迷茫2017-05-16 13:37:12
If you are in an activity, you can use the methods provided by add
show
hide
等一系列getSupportFragmentManager
to manage your frgament