Reputation: 861
I have an App using ViewPager which has 3 tabs. I need each tab to contain a navigation stack of fragments e.g. I have a list on the first fragment which will then display a detail fragment based on clicking an item. What is the best way to design this? At the moment, I have one MainActivity which replaces the Fragments within each tab but as I'm adding more fragments within each tab, the MainActivity will just become huge. Can I handle all of this within the fragments themselves?
Upvotes: 0
Views: 65
Reputation: 30601
I think what you are looking for is a tabhost with backstack. This makes use of a TabHost
, and is not the same as using a ViewPager
with tabs. But that solution on Github is a very good one.
Also, this will not make your MainActivity
"huge", because all the Fragment
s can be defined as separate classes in their own class files. Fragment
s are supposed to represent more modular UI blocks.
Upvotes: 1