title: How to display only selected tab layout in Android created using TabHost
body: <p>I've created a tabbed based application.<br>
  There are <strong>4 Tabs</strong>, I've created 4 Activities </p>
  
  <p>(<strong>HomeActivity</strong>, <strong>SettingsActivity</strong>, <strong>LicenseActivity</strong> and <strong>AboutActivity</strong>) </p>
  
  <p>for the 4 Tabs, with a <strong>MainActivity</strong>. I'm setting the selected Activity as <strong>HomeActivity</strong> I've designed my all 4 Activities when I run the application and whichever Tab I select all the designs of all 4 Activities are displayed.</p>
  
  <p>How can I display the layout of only selected Tab?</p>
  
  <p><strong>Example:</strong> when I select <strong>Settings Tab</strong> then only <strong>SettingsActivity</strong> layout should display..<br><br></p>
  
  <p>My codes is as following:<br><br>
  <strong>MainActivity.java</strong></p>
  
  <pre><code>import android.app.TabActivity;
  import android.content.Intent;
  import android.content.res.Resources;
  import android.os.Bundle;
  import android.widget.TabHost;
  import android.widget.TabHost.TabSpec;
  
  @SuppressWarnings("deprecation")
  public class MainActivity extends TabActivity {
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          Resources ressources = getResources(); 
          TabHost tabHost = getTabHost(); 
  
          // Home tab
          Intent intentHome = new Intent().setClass(this, HomeActivity.class);
          TabSpec tabSpecHome = tabHost
              .newTabSpec("Home")
              .setIndicator("", ressources.getDrawable(R.drawable.icon_home_config))
              .setContent(intentHome);
  
          // Settings tab
          Intent intentSettings = new Intent().setClass(this, SettingsActivity.class);
          TabSpec tabSpecSettings = tabHost
              .newTabSpec("Settings")
              .setIndicator("", ressources.getDrawable(R.drawable.icon_settings_config))
              .setContent(intentSettings);
  
          // License tab
          Intent intentLicense = new Intent().setClass(this, LicenseActivity.class);
          TabSpec tabSpecLicense = tabHost
              .newTabSpec("License")
              .setIndicator("", ressources.getDrawable(R.drawable.icon_license_config))
              .setContent(intentLicense);
  
          // About tab
          Intent intentAbout = new Intent().setClass(this, AboutActivity.class);
          TabSpec tabSpecAbout = tabHost
              .newTabSpec("About")
              .setIndicator("", ressources.getDrawable(R.drawable.icon_about_config))
              .setContent(intentAbout);
  
          // add all tabs 
          tabHost.addTab(tabSpecHome);
          tabHost.addTab(tabSpecSettings);
          tabHost.addTab(tabSpecLicense);
          tabHost.addTab(tabSpecAbout);
  
          //set Home tab as default (zero based)
          tabHost.setCurrentTab(0);
      }
  
  }
  </code></pre>
  
  <p><strong>main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TabHost 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;!-- android:background="#34282C" --&gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:padding="5dp"&gt;
          &lt;TabWidget
              android:id="@android:id/tabs"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content" /&gt;
          &lt;FrameLayout
              android:id="@android:id/tabcontent"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:padding="5dp" &gt;
              &lt;include layout="@layout/home"/&gt;
              &lt;include layout="@layout/settings"/&gt;
              &lt;include layout="@layout/license"/&gt;
              &lt;include layout="@layout/about"/&gt;
          &lt;/FrameLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/TabHost&gt;
  </code></pre>
  
  <p><strong>icon_home_config.xml</strong> and same for other Activities</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;!-- When selected --&gt;
      &lt;item android:drawable="@drawable/icon_home"
            android:state_selected="true" /&gt;
      &lt;!-- When not selected --&gt;
      &lt;item android:drawable="@drawable/icon_home" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p><strong>home.xml</strong> (Here I wanna provide Login form with 2 EditText and a button) and some layout for other Activities</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".HomeActivity" &gt;
  
      &lt;EditText
          android:id="@+id/editText2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/editText1"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="18dp"
          android:ems="10"
          android:inputType="textPassword" &gt;
  
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/editText2"
          android:layout_centerHorizontal="true"
          android:text="Button" /&gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="62dp"
          android:ems="10" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>What I need to add in my code and where exactly I've to add it?</p>