2011-02-10 85 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。你可以在右上角找到下拉列表