2011-02-10 51 views
2

我想尝试在线教程,并希望将该选项卡的布局xml。我已经将Activity的Activity扩展为TabActivity。在布局xml的设计视图中,我有以下内容。任何人都知道这个错误是什么意思的Android标签?

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

我一直在寻求解决方案,但他们没有固定的,除了我发现一个不同的语言。我尝试在谷歌上使用翻译,但没有那么有用。

有没有人设法获得标签功能。

我采用Android 2.2阿比与Eclipse IDE的

回答

1

你有id为Android的一个TabWidget发展:ID /标签的错误消息告诉你你需要什么?

+0

是的我在布局xml中。 – LittleFunny 2011-02-11 03:43:29

+0

我看了一下在ID类下生成的资源文件...我看到了tabhost,tabcontent的id,但tabwidget没有id – LittleFunny 2011-02-11 05:46:26

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

0

我有同样的问题。

评论63布伦德尔... @ gmail.com,2011年5月5日

如上快速修复说明:解决办法是,这个link详述只要改变API目标(左上XML的 图形视图)至3.0,你可以看到它

0

切换到android目标3.0或3.1。你可以在右上角找到下拉列表