使用片段内标签(未FragmentActivity) [英] Using tabs inside a Fragment (not FragmentActivity)
问题描述
我目前正在创建一个应用程序中,主屏幕是建立出2 片段
。
当用户选择主屏幕上的选项,屏幕的一个部分得到由新的片段取代
,所有的pretty很多基本的东西。
I'm currently creating an app in which the main screen is build up out of 2 Fragments
.
When the user selects options on the main screen, one part of the screen gets replaced by a new Fragment
, all pretty much basic stuff.
现在我试图创建一个屏幕,几个标签,这是所有打开里面他们一个新的片段。我有这个工作与常规的意图,但这是切换到片段
之前。
我看,这是可以通过使用 FragmentActivity
,但遗憾的是没人能取代一个片段
与 FragmentActivity
,仅仅是因为该交易将不会放过你。
Now I'm trying to create a screen with several tabs, which all open a new fragment inside them. I had this working with regular intents, but that was before switching to Fragments
.
I read that this is possible by using a FragmentActivity
, but sadly you can't replace a Fragment
with a FragmentActivity
, simply because the transaction won't let you.
是否有这样做一个普通的片段
里面什么办法?或者我应该尝试使用的布局里面它获取由另一人在一个按钮preSS取代片段模仿的行为,就像在主屏幕? (或将不是工作,由于片段的片段?)
Is there any way of doing this inside an ordinary Fragment
? Or should I try mimicking the behavior by using a layout with a fragment inside which gets replaced by another one at the press of a button, much like the main screen? (Or won't that work due to fragments in fragments?)
推荐答案
有一个在Android的支持库描述似乎是你所需要的一个例子。你可以在这里找到它:<一href=\"http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.html\"相对=nofollow> FragmentTabs
。
There is an example in Android's support library that describes what seems to be what you need. You can find it here: FragmentTabs
.
这篇关于使用片段内标签(未FragmentActivity)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!