I used below code and it is not render graphical layout. display error as Exception raised during rendering: No tab known for tag null
.
how can i solve this ?
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<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>
My develop environment is Android Studio 0.8.9 with API19 SDK.
If I put the FragmentTabHost in a FragmentActivity, it works. When I put the FragmentTabHost in a Fragment, it gets "no tab known for tag null" when render and get runtime error when LayoutInflater inflate the layout.
Thank for user3216049's answer, it's a good workaround. Sorry, I cannot vote since I am a newbie. :(
However it display nothing in my test tab fragments. I did a small modification.
This problem occurs when you try to setup your FragmentTabHost in onViewCreated, which is too late. Try to setup it in onCreateView, and add at least one tab before returning the view object.
This is the code that I've used to initialise the TabHost and it works fine:
It seems there is a bug in android support library.
I finally found this workaround:
Changed layout file as this one:
Then i created by code FragmentTabHost as this example:
i solve my problem by refering this link
FragmentTabHost - No tab known for tag null
No tab known for tag null its Means tabhost is not initialized yet becouse you are trrying in onCreateView method which is too late
call tabhost in onResume method
I got a similar problem on using tabHost in fragments, searched a lot and finally found a solution to that.
1) Keep you code in on create view
2) This is the key -> While inflating the layout for tab indicators use as follows
We need to set the parent value in the inflater as
mTabHost.getTabWidget()
Setting tab indicator using the above code solved the issue of
Update :