Reputation: 1666
I have created an app using Fragments throughout, as per the guidelines, so that I can show more detailed views on larger screens. However I also want to use tabs for navigation, which as per the guidelines should also be fragments rather than the deprecated TabHost.
Some Googling has shown that you can't / shouldn't nest fragments. My question is what are you meant to do if you want to have tabs, but you also want to support fragments for different size devices? Should I be removing the fragments and making two separate activities for phones and tablets?
Making it more confusing, the design guidelines here, show tabbed navigation and then what looks like a fragment activity. Is this a case of nested fragments or are they separate activities?
Upvotes: 4
Views: 3755
Reputation: 8477
There is an API demo a code sample that demonstrates combining a ViewPager
and a TabHost
to switch Fragments: Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager
If you don't like TabHost
, here is another example of the same code but using ActionBar tabs and ActionBarSherlock: http://code.google.com/p/sherlock-demo/
Upvotes: 3