片段标签和片段活动 [英] Fragment Tabs and Fragment Activities
问题描述
我已经创建了整个片段使用一个应用程序,按照指引,这样我就可以显示在大屏幕更详细的意见。不过,我也想用的导航标签,它按照准则也应是片段而不是pcated去$ P $ TabHost。
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?
推荐答案
有一个API演示,演示了结合了code样本 ViewPager
和 TabHost
切换片段: Support4Demos / src目录/ COM /例子/安卓/ supportv4 /应用/ FragmentTabsPager
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
如果你不喜欢 TabHost
,这里是一样的code的另一个例子,但使用动作条选项卡和ActionBarSherlock:的 HTTP://$c$c.google.com/p/sherlock-demo/
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/
这篇关于片段标签和片段活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!