Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android TabWidget集id_Java_Android_Xml - Fatal编程技术网

Java Android TabWidget集id

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代码用于我的应用程序

<?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
,阅读本指南以更清楚地了解选项卡的工作方式。