How to make particular tab in FragmentTabHost has multiple fragment navigations like tabgroupactivity

孤者浪人 提交于 2019-12-04 18:09:38
Stephen Asherson

The concept of different fragment navigation stacks in each tab has been discussed quite a few times on stackoverflow, one example for instance:

Separate Back Stack for each tab in Android using Fragments

One simple/crude way of achieving this without having to manage your own custom navigation back stack is to have a root fragment under each tab, and then whenever a root fragment wants to navigate to another fragment (fragment B) simply show a new Activity initially with fragment B and that Activity will have its own fragment navigation back stack.

Tab1 --->root frag1 --> Activity (own nav back stack) --> frag2

Tab2 --->root frag3

Tab3 --->root frag4 --> Activity (own nav back stack) --> frag5 --> frag6 --> frag7

An example of an app that does something like this is actually the StackAnywhere app. It makes heavy use of tabs, but when you navigate within those tabs it generally moves the navigation to a new Activity. YMMV with this approach, however.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!