【发布时间】:2013-06-10 07:18:07
【问题描述】:
我正在使用标签主机来显示标签,但即使我只是将它拖放到我的布局上并运行它,它也不显示标签,它显示白屏,我猜这是第一个线性布局选项卡视图。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
当我在模拟器或手机(Huawei Ascend P1)上运行时,没有显示任何选项卡。
【问题讨论】:
-
你添加了一些标签吗?
-
标签被添加到 xml 布局中。你的意思是通过编程添加标签?
-
是的,在代码中添加了标签。
-
看看这是否有帮助:stackoverflow.com/a/16662379/1893766
标签: android tabs android-tabhost