Java Android TabWidget集id
我有这个xml代码用于我的应用程序Java Android TabWidget集id,java,android,xml,Java,Android,Xml,我有这个xml代码用于我的应用程序 <?xml version="1.0" encoding="utf-8"?> <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"
<?xml version="1.0" encoding="utf-8"?>
<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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none"
android:layout_weight="1">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip" />
</HorizontalScrollView>
<Button android:id="@+id/add_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:text="Add"/>
</LinearLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="2dp" />
</LinearLayout>
</TabHost>
当我将TabWidget ID从android:ID=“@android:ID/tabs”
设置为android:ID=“@+ID/tabs”
时,它会向我显示一条警告,当我启动应用程序时,它会崩溃
警告:
呈现期间引发异常:TabHost需要具有
id“安卓:id/tabs”
它在
TabHost
中也不起作用。为什么不使用片段和操作选项卡?它们的可扩展性更好,用户友好度也更高。因此,如果您有任何代码,或者您现在有任何教程,请告诉我,我是android应用程序的新手。请看这里:@androbat我如何在MainActivity.java中选择TabWidget
或TabHost
,阅读本指南以更清楚地了解选项卡的工作方式。