简体   繁体   中英

Fragment Tabs and Fragment Activities

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?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM