Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - FragmentTabHost Error "No tab known for tag null"

Tags:

android

tabs

xml

I have the following XML:

<FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/frmTabs"
        android:layout_below="@+id/ibTop"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@+id/vlImagesRight"
        android:layout_marginRight="10dp"
        android:layout_marginTop="0dp"
        android:layout_marginLeft="5dp"
        android:layout_marginBottom="5dp">

        <android.support.v4.app.FragmentTabHost
        android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/tabHost">

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">

                <TabWidget
                android:id="@+id/tabWidget"
                android:layout_width="fill_parent"
                android:layout_alignParentBottom="true"
                android:layout_height="wrap_content" />

                <FrameLayout
                    android:id="@+id/tabContent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent">
                    <LinearLayout
                    android:id="@+id/tab_a"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"/>

                    <LinearLayout
                        android:id="@+id/tab_b"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"/>

                    <LinearLayout
                        android:id="@+id/tab_c"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"/>
                </FrameLayout>
            </RelativeLayout>
        </android.support.v4.app.FragmentTabHost>
    </FrameLayout>

And my Android Studio shows this error:

Exception raised during rendering: No tab known for tag null

Commenting the <android.support.v4.app.FragmentTabHost key and it's children makes the error go away.

I can find threads like this one, but I wonder if after all this time it still doesnt have a simpler solution, like in the XML itself.

like image 809
Michel Feinstein Avatar asked Jun 15 '14 04:06

Michel Feinstein


1 Answers

Change Layout to

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

<FrameLayout
    android:id="@+id/realtabcontent"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1" />

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


    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="0" />
</android.support.v4.app.FragmentTabHost>

</LinearLayout>
like image 82
Ram Avatar answered Oct 20 '22 21:10

Ram