2011-01-06 10 views
4

Possible Duplicate:
Anyone know what this error mean for android tabs?Tabhostチュートリアルが壊れていますか?

私はSDKでTabHostチュートリアルを実行しようとしていましたが、何らかの理由で破損しているようです。ステップ4でXMLコードをコピーして貼り付けると、正しく膨張しないようにするエラーが表示されます。エラーは次のとおりです。

Error in an XML file: aborting build. 

これはXMLファイルのグラフィカルレイアウトです。

Error during post inflation process: 
TabHost requires a TabWidget with id "android:id/tabs", 
View found with id "tabs" is 'com.android.layoutlib.bridge.MockView' 

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: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> 

何か問題がありますか?

+0

これをテストプロジェクトなどで実行していますか? TabViewクラスが 'com.android.layoutlib.bridge.MockView'によって上書きされているようです。私は前にそのエラーを見たことがない。 – Falmarri

+0

テストプロジェクトはありません。私はcom.android.layoutlib.bridge.MockViewがどこにあるか分からない。私が欲しかった。 –

+0

[ここ](http://stackoverflow.com/questions/4963773/anyone-know-what-this-error-mean-for-android-tabs/5017740#5017740)は同じ質問の答えです。 – ercu

答えて

2

このテンプレートを使用:Android Tools

<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:id="@+id/tab" android:orientation="vertical"  android:layout_width="fill_parent" android:layout_height="fill_parent"> 
     <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"> 

      <LinearLayout android:id="@+id/tab1" android:layout_width="fill_parent" 
      android:layout_height="fill_parent" android:orientation="vertical"/> 

      <LinearLayout android:id="@+id/tab2" android:layout_width="fill_parent" 
      android:layout_height="fill_parent" android:orientation="vertical"/> 

</FrameLayout> 
</LinearLayout> 
</TabHost> 
+1

raybrittonによって投稿されたものを試した後、私はこのエラーを受け取ります: error! RuntimeException:IDが-1のビューが見つからないため、タブのコンテンツを作成できませんでした。 –

+0

@TiagoAfonso FYI、Androidツール[バグレポート](http://code.google.com/p/android/issues/detail ?id = 37631)。 –

2

参照ステップ5を、あなたの活動は、あなたがここで見つける更新レンダリングライブラリを使用することができない活動

Now open HelloTabWidget.java and make it extend TabActivity:

0

、TabActivityを拡張する必要があります。

\layoutlib\[platform version]から\[sdk dir]\platforms\[platform version]にあるディレクトリを抽出し、layoutlibよりも優先させるようにしてください。

0

グラフィックレイアウト自体でアンドロイドターゲット3.0または3.1に切り替えます。ドロップダウンリストは右上にあります

+0

これはエラーに影響を与えていないようです。 – cdonner

+0

私は最新のスタック(ADT 16.0.1)を公開しています。私は1.5から4.0.2までのビルドされたターゲットを試しましたが、常にこのエラーが発生します。 – cdonner

関連する問題