2

フレームレイアウトがクリックされたナビゲーション項目に関連付けられたフラグメントを表示する ActionBar listnavigation を使用するアクティビティがあります。ここまでは順調ですね。

これらのフラグメントの 1 つに、FragmentTabHost を含むレイアウトがあります。具体的には、レイアウトは次のようになります (簡略化)。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="96dp"
        android:orientation="vertical">

    <TextView 
        android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textStyle="italic"
            android:textSize="12sp"
            android:text="@string/user_creation_date"/>
    <TextView
            android:id="@+id/user_joinDate"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textStyle="normal"
            android:textSize="16sp"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/profile_header">

    <android.support.v4.app.FragmentTabHost
            android:id="@android:id/tabhost"
            android:layout_height="match_parent"
            android:layout_width="match_parent">

       <LinearLayout
           android:orientation="vertical"
           android:layout_width="match_parent"
           android:layout_height="match_parent">

           <TabWidget
               android:id="@android:id/tabs"
               android:orientation="horizontal"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_weight="0"/>

           <FrameLayout
               android:id="@android:id/tabcontent"
               android:layout_width="0dp"
               android:layout_height="0dp"
               android:layout_weight="0"/>

            <FrameLayout
                android:id="@+id/realtabcontent"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"/>
        </LinearLayout>
    </android.support.v4.app.FragmentTabHost>
</LinearLayout> 
</RelativeLayout>

私のフラグメントでは、Android ドキュメントに示されているように、「onActivityCreated」で FragmentTabHost を初期化します。今私の問題に; フラグメントを表示しようとすると、次のエラーが表示されます。

E/AndroidRuntime(20242): FATAL EXCEPTION: main
E/AndroidRuntime(20242): java.lang.IllegalStateException: No tab known for tag null

FragmentTabHost で怪しいことが起こっていることを示す 1 つのスレッドを見つけましたが、私の質問/問題には答えませんでした: Android FragmentTabHost - まだ完全に焼き付けられていませんか?

FragmentTabHost で同様の経験をした人はいますか? 誰かがこの動作を説明できますか?

注: FragmentActivity のレイアウト XML に (コードを変更せずに) 同じフラグメントを (宣言して) 含めても、<fragment>何の問題も発生しません。

4

0 に答える 0