title: com.example.main cannot be cast to android.support.v4.app.Fragment
body: <p>Just following the basic android documentation on <a href="https://developer.android.com/reference/android/support/v4/app/FragmentTabHost.html" rel="nofollow">FragmentTabHost</a> (top example - FragmentTabHost in an Activity) and received the following error:</p>
  
  <pre><code>10-21 02:30:07.409  26265-26265/com.example E/AndroidRuntime﹕ FATAL EXCEPTION: main
  java.lang.ClassCastException: com.example.Main cannot be cast to android.support.v4.app.Fragment
  </code></pre>
  
  <p>What's strange is that I've followed everything properly and installed the necessary packages.</p>
  
  <p><strong>Main.java</strong></p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentTabHost;
  
  public class Main extends FragmentActivity {
      // Fragment TabHost as mTabHost
      private FragmentTabHost mTabHost;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
          mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
  
          mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("Tab1"),
                  Main.class, null);
          mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("Tab2"),
                  ListNewItem.class, null);
          mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator("Tab3"),
                  Favourites.class, null);
          mTabHost.addTab(mTabHost.newTabSpec("tab4").setIndicator("Tab4"),
                  Notifications.class, null);
      }
  }
  </code></pre>
  
  <p><strong>main.xml</strong></p>
  
  <p><strong>Note:</strong> Intellij displays the following in the side-window when attempting to display a preview:</p>
  
  <blockquote>
    <p>Rendering Problems Exception raised during rendering: No tab known for
    tag null</p>
  </blockquote>
  
  <p>Library bug maybe?</p>
  
  <pre><code>&lt;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"&gt;
  
      &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" &gt;
  
          &lt;TabWidget
                  android:id="@android:id/tabs"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="0"
                  android:orientation="horizontal" /&gt;
  
          &lt;FrameLayout
                  android:id="@android:id/tabcontent"
                  android:layout_width="0dp"
                  android:layout_height="0dp"
                  android:layout_weight="0" /&gt;
  
          &lt;FrameLayout
                  android:id="@+id/realtabcontent"
                  android:layout_width="match_parent"
                  android:layout_height="0dp"
                  android:layout_weight="1" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/android.support.v4.app.FragmentTabHost&gt;
  </code></pre>
  
  <p><strong>Manifest.xml</strong></p>
  
  <pre><code>&lt;activity android:name=".Main"
          android:label="@string/main"
          android:uiOptions="splitActionBarWhenNarrow" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
          &lt;/intent-filter&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p><strong>Notifications.java (badly named fragment)</strong></p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class Favourites extends Fragment  {
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View V = inflater.inflate(R.layout.favourites, container, false);
  
          return V;
      }
  }
  </code></pre>
  
  <p>Does anyone know why I'm having the problems with both the rendering and why the class conversion isn't working? </p>