【发布时间】:2014-12-19 19:57:09
【问题描述】:
我有一个选项卡主机,我想为所有三个选项卡使用相同的布局文件。但是当我尝试这样做时,我只能看到其中一个选项卡上的布局,而不是全部三个。
myTabHost =(TabHost) findViewById(R.id.TabHost01);
myTabHost.setup();
TabHost.TabSpec spec1 = myTabHost.newTabSpec("First Tab");
spec1.setIndicator("First Tab", getResources().getDrawable(android.R.drawable.ic_menu_add));
spec1.setContent(R.id.tab1);
myTabHost.addTab(spec1);
myTabHost.addTab(myTabHost.newTabSpec("Tab Two").
setIndicator("Tab Two", getResources().getDrawable(android.R.drawable.ic_menu_edit)).setContent(R.id.tab1));
然后在我的选项卡主机 xml 活动中,我有
<TabHost
android:id="@+id/TabHost01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TabWidget>
<!-- container of tabs -->
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
layout="@layout/item_list_view">
但是在选项卡二上我没有看到 item_list_view?
如何为两个选项卡使用相同的 xml?
感谢您的帮助
【问题讨论】:
标签: android xml android-tabhost