In the example below, two tabs named Audio and Video will be created.

Code

public class MyTabbedScreen extends TabActivity implements OnTabChangeListener {

 private TabHost tabHost;

 @Override
  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabbed_screen);

        /* TabHost will have Tabs */
        tabHost = (TabHost) findViewById(android.R.id.tabhost);
        tabHost.setOnTabChangedListener(this);

        /* TabSpec used to create a new tab.
         * By using TabSpec only we can able to setContent to the  .
        * By using TabSpec setIndicator() we can set name to tab. */

        /* tid1 is firstTabSpec Id. Its used to access outside. */
        TabSpec audioTabSpec = tabHost.newTabSpec("audio");
        TabSpec videoTabSpec = tabHost.newTabSpec("video");


        /* TabSpec setIndicator() is used to set name for the tab. */
        /*  TabSpec setContent() is used to set content for a particular tab. */

        audioTabSpec.setIndicator("Audio",  getResources().getDrawable(R.drawable.audio));
         videoTabSpec.setIndicator("Video", getResources().getDrawable(R.drawable.video));


        TextView audioContent = new TextView(this);
        audioContent.setText("Listen to Audio");
         audioTabSpec.setContent(audioContent.getId());

        TextView videoContent = new TextView(this);
        videoContent.setText("Watch the Video");
        videoTabSpec.setContent(videoContent.getId());

        /* Add tabSpec to the TabHost to display. */
        tabHost.addTab(audioTabSpec);
        tabHost.addTab(videoTabSpec);


        }
}