Reputation: 1075
I've found some discussions related to this issue but nothing clear or definitive.
Building a tab-based application, one seems forced to choose between (A) using TabHost with Activities for each screen, and (B) using the ActionBar with Fragments for each screen. This raises a few questions:
1) Is that dilemma for real, or can one use the ActionBar with different Activities.
2) If the dilemma is for real, why are things set up this way? Is Google planning to deprecate TabHost and the multiple-Activities approach to tab-based navigation? Is there something unsavory about the multiple-Activities approach?
3) If both approaches will continue to be supported, what are the pros and cons of each? If I go with ActionBar+Fragments, will I run into any gotchas down the line? For example, when I want one of my tabbed screens to slide over/pop-on an additional screen/Fragment, will I get funny behavior switching to/from tabs in the ActionBar?
Upvotes: 9
Views: 4993
Reputation: 5071
I'm with you. I began developing "Droid Bones" (be sure to use the quotes) before the advent of Fragments. When I began looking at that architecture, it appeared that it would not accommodate my structural requirements. That said, I've found the multiple-activity approach to be very fluid and flexible. My concern is that some of the TabHost documentation appears to have 'gone missing' of late!
Upvotes: 1
Reputation: 8255
You also have the third option of using a TabHost with Fragments. This makes it to where you only have one activity and multiple fragments as the children.
http://developer.android.com/reference/android/support/v4/app/FragmentTabHost.html
I have created a simple example using this class.
https://github.com/marsucsb/nested-fragments
Upvotes: 3