http://www.mkyong.com/android/android-tablayout-example/


http://developer.android.com/training/improving-layouts/optimizing-layout.html


http://androidwid.blogspot.kr/2012/08/android-tablayout-example.html


http://www.androidhive.info/2011/08/android-tab-layout-tutorial/


http://blog.callumtaylor.net/howtocreatecustomlayoutswithxmlattritubesjava-android



http://eternalnoob.livingcode.info/android-nested-tabhost/


http://androiddev.orkitra.com/?p=25667



Android TabLayout example


In this example we have three tab as follows. you can move in the any tab at by clicking on the Tab. as follows 
TAB1.png

  1. First we design the XML layout as follows 

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <?xml version="1.0" encoding="utf-8"?>
     android:id="@android:id/tabhost" android:layout_width="match_parent"
     android:layout_height="match_parent">
     <LinearLayout android:id="@+id/linearLayout1"
      android:layout_width="match_parent" android:layout_height="match_parent"
      android:orientation="vertical">
      <TabWidget android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:id="@android:id/tabs"></TabWidget>
      <FrameLayout android:layout_width="match_parent"
       android:layout_height="match_parent" android:id="@android:id/tabcontent">
        
      </FrameLayout>
     </LinearLayout>
    </TabHost>


  2.  Create the Activtity file for diffrent Tab Activities we have create three diffrent Activity : ActivityA, ActivityB, ActivityC as follows


  3. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    package com.container;
     
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
     
    public class ActivityA extends Activity {
     
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         TextView tv=new TextView(this);
         tv.setText("I am in Tab A..");
         setContentView(tv);
         // TODO Auto-generated method stub
     }
     
    }
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    package com.container;
     
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
     
    public class ActivityB extends Activity {
     
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         TextView tv=new TextView(this);
         tv.setText("I am in Tab B..");
         setContentView(tv);
         // TODO Auto-generated method stub
     }
     
    }
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    package com.container;
     
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
     
    public class ActivityC extends Activity {
     
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         TextView tv=new TextView(this);
         tv.setText("I am in Tab C..");
         setContentView(tv);
         // TODO Auto-generated method stub
     }
     
    }
  4. Than we Create Our main Activity as follows code..


  5. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    package com.container;
     
    import android.app.TabActivity;
    import android.content.Intent;
    import android.content.res.Resources;
    import android.os.Bundle;
    import android.widget.TabHost;
     
    public class TabViewDemoActivity extends TabActivity {
        /** Called when the activity is first created. */
     Resources res;
     TabHost tabHost;
     TabHost.TabSpec spec;
     Intent intent;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
             
            res=getResources();
            tabHost=getTabHost();
             
            /**Create Tab A**/
            intent=new Intent().setClass(this,ActivityA.class);
            spec=tabHost.newTabSpec("A")
              .setIndicator("A",res.getDrawable(R.drawable.ic_btn_speak_now))
              .setContent(intent);
            tabHost.addTab(spec);
             
            /**Create Tab B**/
            intent=new Intent().setClass(this,ActivityB.class);
            spec=tabHost.newTabSpec("B")
              .setIndicator("B",res.getDrawable(R.drawable.ic_btn_speak_now))
              .setContent(intent);
            tabHost.addTab(spec);
             
            /**Create Tab C**/
            intent=new Intent().setClass(this,ActivityC.class);
            spec=tabHost.newTabSpec("C")
              .setIndicator("C",res.getDrawable(R.drawable.ic_btn_speak_now))
              .setContent(intent);
            tabHost.addTab(spec);
        }
    }


that it, Run your app you can move on any Tab By clicking on that as follows 
TAB2.png