首先,谢谢大家这个伟大的社区.
我试图遵循支持演示示例代码来实现选项卡式片段接口.
顶级,我正在尝试实现两个选项卡,将单个片段与每个选项卡关联,并在相应选择每个选项卡时显示片段.
目前,我有两个问题(但我相信它们是相关的......)
1)每个标签的片段彼此重叠.这可能与不正确的片段附加/分离有关.
2)在某处创建了第三个神秘片段,并与其他片段重叠
当选择tab1时,片段1和未知片段重叠.
当选择tab2时,片段1和片段2重叠.
链接到屏幕截图(上传照片的声誉不够......)
(tab1重叠)http://s8.postimg.org/kv81yz745/tab1_overlapping.png
(tab2重叠)http://s8.postimg.org/3tf7wvs91/tab2_overlapping.png
在这里,为了演示/清晰的目的,我将每个片段中的文本分开.
这些屏幕截图的链接位于我的评论/回复中.(没有足够的声誉来上传超过2个链接...)
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
public class TabbedInfoHome extends SherlockFragmentActivity {
TabHost mTabHost;
TabManager mTabManager;
static String tag1name = "simple1";
static String tag2name = "simple2";
static String tab1string = "You are looking at fragment 1"; …
Run Code Online (Sandbox Code Playgroud)