0

我使用 TabLayout 创建了一个带有 2 个选项卡的应用程序...

我需要将该应用程序与另一个应用程序集成。但是当我到达标签页时,它最终出现错误

java.lang.RuntimeException:无法启动活动 ComponentInfo{com.android/com.android.simphone.SimFoneDetailsActivity}:java.lang.RuntimeException:您的内容必须有一个 id 属性为“android.R.id.tabhost”的 TabHost

我更改了TabHost的ID,但没有用......欢迎任何建议......

代码的xml部分也附在...

<TabHost 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/bg_sim">
<LinearLayout 
android:id="@+id/LinearLayout01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget 
android:id="@+id/tabs" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"></TabWidget>
<FrameLayout 
android:id="@+id/tabcontent" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"></FrameLayout>
</LinearLayout>
</TabHost>
4

2 回答 2

1

你的布局 xml 代码是什么?你是这样写的吗:

<TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
......
</>
于 2012-04-07T05:00:59.007 回答
1

试试这个

<TabHost 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/bg_sim">
<LinearLayout 
android:id="@+id/LinearLayout01" 
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>
<FrameLayout 
android:id="@android:id/tabcontent" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"></FrameLayout>
</LinearLayout>
</TabHost>

请注意,要使选项卡正常工作,您需要使用此@android:id/

于 2012-04-07T05:28:43.113 回答