Activity inherited from TabActivity
Public class TabActivityDemo extends TabActivity {
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetTitle ("TabDemoActivity ");
TabHost tabHost = getTabHost ();
LayoutInflater. from (this). inflate (R. layout. tab_demo,
TabHost. getTabContentView (), true );
TabHost. addTab (tabHost. newTabSpec ("tab1"). setIndicator ("tab1"). setContent (R. id. view1 ));
TabHost. addTab (tabHost. newTabSpec ("tab2"). setIndicator ("tab2"). setContent (R. id. view2 ));
TabHost. addTab (tabHost. newTabSpec ("tab3"). setIndicator ("tab3"). setContent (R. id. view3 ));
}
}
Tab_demo.xml
<? Xml version = "1.0" encoding = "UTF-8"?>
<FrameLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
<TextView android: id = "@ + id/view1"
Android: background = "@ drawable/blue"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: text = "here is the content in tab1. "/>
<TextView android: id = "@ + id/view2"
Android: background = "@ drawable/red"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: text = "here is Tab2, balabalal ..... "/>
<TextView android: id = "@ + id/view3"
Android: background = "@ drawable/green"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: text = "Tab3"/>
</FrameLayout>
From the ch_jinyi Column