Skip to content Skip to sidebar Skip to footer

Android : Using Tab View With Dynamic Fragment

I have created an application which contains tab view and dynamic fragments concepts. the code was earlier working fine when when i was switching to different activity on pressing

Solution 1:

You are trying to cast a TabHost to FragmentTabHost

try this

<android.support.v4.app.FragmentTabHostxmlns:android="http://schemas.android.com/apk/res/android"android:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><TabWidgetandroid:id="@android:id/tabs"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="0"android:orientation="horizontal" /><FrameLayoutandroid:id="@+id/tabFrameLayout"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1" /></LinearLayout>

</android.support.v4.app.FragmentTabHost >

Solution 2:

There is a class cast excption in your main activity

mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);

findviewbyid(android.R.id.tabhost); android.R.id.tabhost???? check this line and you will not get this error.

Post a Comment for "Android : Using Tab View With Dynamic Fragment"