title: How to add another fragment on the existing fragment?
body: <p>I am trying to create <code>tab layout with fragments</code>. When i add another fragment on item click it should show another fragment above it. I am unable to get the goal. Fragment just goes above the existing one but both the fragments content are visible. Please don't throw the link towards any developer page for explanation. </p>
  
  <p>Here is my code </p>
  
  <p><strong><code>home_activity.xml</code></strong></p>
  
  <p></p>
  
  <pre><code>&lt;TabHost
      android:id="@android:id/tabhost"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentBottom="true" &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" &gt;
          &lt;/TabWidget&gt;
  
          &lt;FrameLayout
              android:id="@android:id/tabcontent"
              android:layout_width="match_parent"
              android:layout_height="match_parent" &gt;
  
              &lt;fragment
                  android:id="@+id/tab1"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  class="com.example.tabsfragment.School_Fragment" &gt;
              &lt;/fragment&gt;
  
              &lt;fragment
                  android:id="@+id/tab2"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  class="com.example.tabsfragment.Sports_Fragment" &gt;
              &lt;/fragment&gt;
          &lt;/FrameLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/TabHost&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong><code>Home_Activity.java</code></strong></p>
  
  <pre><code>public class Home_Activity extends FragmentActivity {
  
  TabHost mHost;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.home_activity);
  
      mHost = (TabHost) findViewById(android.R.id.tabhost);
  
      mHost.setup();
  
      TabSpec schoolSpec = mHost.newTabSpec("School").setIndicator("School")
              .setContent(R.id.tab1);
      mHost.addTab(schoolSpec);
  
      TabSpec sportSpec = mHost.newTabSpec("Sports").setIndicator("Sportss")
              .setContent(R.id.tab2);
      mHost.addTab(sportSpec);
  
      mHost.setCurrentTab(1);
  
  }
  </code></pre>
  
  <p><strong><code>entertainment.xml</code></strong></p>
  
  <p>
  </p>
  
  <pre><code>&lt;FrameLayout
      android:id="@+id/frameContainer"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Button" /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>I am adding another fragment on <code>list_item_click</code> inside <code>Sports_Fragment</code> </p>
  
  <pre><code>@Override
      public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
          // TODO Auto-generated method stub
  
          FragmentTransaction ft = getFragmentManager().beginTransaction();
          Entertainment_Fragment enFragment = new Entertainment_Fragment();
          ft.replace(android.R.id.tabcontent, enFragment);
          ft.commit();
      }
  </code></pre>
  
  <p>Here is the snapshot :</p>
  
  <p><img src="https://i.stack.imgur.com/MvquF.png" alt="Screenshot"></p>
  
  <p>Any ideas/help with explanation would be highly appreciated.</p>
  
  <p>Thanks!!</p>