任何人都知道这个错误对android标签意味着什么?

时间:2011-02-10 23:09:11

标签: android layout tabs host

我正在尝试在线试用教程,并希望将标签放到布局xml中。我已将Activity的扩展名更改为TabActivity。在布局xml的设计视图中,我有以下内容。

后期通胀过程中的错误: TabHost需要一个ID为“android:id / tabs”的TabWidget。 找到id为'tabs'的视图是'com.android.layoutlib.bridge.MockView' 找不到以下类:

我已经找到了解决方案,但除了我用不同的语言找到了解决方案之外没有其他解决方法。我尝试在谷歌上使用翻译,但没有那么有用。

是否有人设法让标签功能化。

我正在使用Android 2.2 Api并使用eclipse IDE进行开发

5 个答案:

答案 0 :(得分:3)

已知错误http://code.google.com/p/android/issues/detail?id=13092

用户建议将构建目标切换为1.6,问题就会消失。显然是临时修复。

答案 1 :(得分:2)

你需要这样的布局:

<?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:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>

有关详细信息,请参阅Tab Layout tutorial

答案 2 :(得分:1)

你有一个带有id:android:id / tabs的TabWidget,因为错误信息告诉你需要吗?

答案 3 :(得分:0)

我有同样的问题。解决方法详见此link

  

评论63 by blundell ... @ gmail.com,2011年5月5日

     

如上所述快速修复:只需更改API目标(XML的左上角)   图形视图)到3.0,你可以看到它

答案 4 :(得分:0)

切换到android Target 3.0或3.1。您可以在右上角找到该下拉列表