title: Fragment Activity in tabhost "cannot be cast to android.support.v4.app.Fragment"
body: <p>I have already implemented one application using TabActivity. Now, I want change from TabActvity to Fragments, but in my application I need to show 4 tabs and each tab. Previously I had created TabActivity, now when i change to fragment, i have an eror... this is my layout :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@android:id/tabhost"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
      &lt;RelativeLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
      &gt;
          &lt;TabWidget
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:id="@+id/tabsHeader"
              android:layout_alignParentBottom="false"
              android:tabStripEnabled="false"
              android:hapticFeedbackEnabled="true"
              android:background="@drawable/epolicy_header_logo"
          /&gt;
          &lt;FrameLayout
              android:id="@android:id/tabcontent"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" 
              android:layout_marginTop="40dp"
              android:layout_marginBottom="45dp"
          /&gt;
  
          &lt;TabWidget
              android:id="@android:id/tabs"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_alignParentLeft="true"
              android:background="@drawable/epolicy_menu_bar"
              android:tabStripEnabled="false" &gt;
          &lt;/TabWidget&gt;
  
      &lt;/RelativeLayout&gt;
  &lt;/android.support.v4.app.FragmentTabHost&gt;
  </code></pre>
  
  <p>this is my activity :</p>
  
  <pre><code>public class EpolicyMainActivity extends FragmentActivity {
  private FragmentTabHost tabHost;
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
      //hide title bar
      BasicDisplaySettings.toggleTaskBar(EpolicyMainActivity.this, false);
      //show status bar
      BasicDisplaySettings.toggleStatusBar(EpolicyMainActivity.this, true);
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.epolicy);
      tabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
      tabHost.setup(this, getSupportFragmentManager(),android.R.id.tabcontent);
      Resources res = getResources(); 
      Intent intent;  
  
      tabHost.addTab(tabHost.newTabSpec("Login").setIndicator("Login",
                res.getDrawable(R.drawable.epolicy_menu_xml_home)),
                LoginActivity.class,null);
  
  
      tabHost.addTab(tabHost.newTabSpec("NAB").setIndicator("NAB",
              res.getDrawable(R.drawable.epolicy_menu_xml_nab)),
              NABActivity.class,null);
  
  
  
      tabHost.addTab(tabHost.newTabSpec("Contact").setIndicator("Contact",
              res.getDrawable(R.drawable.epolicy_menu_xml_contact)),
              ContactActivity.class,null);
  
  
      tabHost.addTab(tabHost.newTabSpec("Agen").setIndicator("Agen",
              res.getDrawable(R.drawable.epolicy_menu_xml_agen)),
              AgenActivity.class,null);
  
  
  
  }
  </code></pre>
  
  <p>is there any wrong in my code..? i have try to import </p>
  
  <pre><code>import android.support.v4.app.Fragment;
  
      android.support.v4.app.FragmentActivity;
      import android.support.v4.app.FragmentTabHost;
  </code></pre>
  
  <p>but the log cat still say  <code>cannot be cast to android.support.v4.app.Fragment</code>.</p>
  
  <p>i hope somebody can tell me and show me where is my fault.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>this is my logcat</p>
  
  <pre><code>05-28 13:39:59.780: E/AndroidRuntime(15156): FATAL EXCEPTION: main
  05-28 13:39:59.780: E/AndroidRuntime(15156): java.lang.ClassCastException: id.co.ajsmsig.epolicy.LoginActivity cannot be cast to android.support.v4.app.Fragment
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.support.v4.app.FragmentTabHost.doTabChanged(FragmentTabHost.java:339)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.support.v4.app.FragmentTabHost.onAttachedToWindow(FragmentTabHost.java:276)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.view.View.dispatchAttachedToWindow(View.java:9831)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2198)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2206)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2206)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2206)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:953)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2459)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.os.Handler.dispatchMessage(Handler.java:99)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.os.Looper.loop(Looper.java:137)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at android.app.ActivityThread.main(ActivityThread.java:4514)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at java.lang.reflect.Method.invokeNative(Native Method)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at java.lang.reflect.Method.invoke(Method.java:511)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
  05-28 13:39:59.780: E/AndroidRuntime(15156):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>