Package com. Android. tabhost;
Import Android. App. tabactivity;
Import Android. Graphics. color;
Import Android. OS. Bundle;
Import Android. util. log;
Import Android. View. layoutinflater;
Import Android. widget. tabhost;
Import Android. widget. tabhost. ontabchangelistener;
Public class tabactivtiy extends tabactivity {
Private string tag = "= tabactivtiy = ";
Private tabhost mhost;
@ Override
Public void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Mhost = gettabhost ();
Layoutinflater. From (this). Inflate (R. layout. Main, mhost. gettabcontentview (), true );
Mhost. setbackgroundcolor (color. argb (80,128,128,128 ));
Mhost. addtab (mhost. newtabspec ("AA "). setindicator ("aaaaaa", getresources (). getdrawable (R. drawable. icon )). setcontent (R. id. one ));
Mhost. addtab (mhost. newtabspec ("BB "). setindicator ("bbbbbb", getresources (). getdrawable (R. drawable. icon )). setcontent (R. id. two ));
Mhost. addtab (mhost. newtabspec ("cc "). setindicator ("cccccc", getresources (). getdrawable (R. drawable. icon )). setcontent (R. id. three ));
Mhost. setontabchangedlistener (New ontabchangelistener (){
@ Override
Public void ontabchanged (string Tabid ){
Log. I (TAG, "= Tabid =" + Tabid); // Tabid is aa BB CC
}
});
// Setcontentview (R. layout. Main );
}
}
<? 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">
<Linearlayout Android: Id = "@ + ID/One"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
Androidrientation = "vertical">
<Textview Android: Id = "@ + ID/one_txt"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "one"
/>
<Imageview Android: Id = "@ + ID/one_image"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: Background = "@ drawable/icon"/>
</Linearlayout>
<Linearlayout Android: Id = "@ + ID/Two"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
Androidrientation = "vertical">
<Textview Android: Id = "@ + ID/two_txt"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "two"
/>
<Imageview Android: Id = "@ + ID/two_image"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: Background = "@ drawable/icon"/>
<Imageview Android: Id = "@ + ID/two_image_two"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: Background = "@ drawable/icon"/>
</Linearlayout>
<Linearlayout Android: Id = "@ + ID/three"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
Androidrientation = "vertical">
<Textview Android: Id = "@ + ID/three_txt"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "three"
/>
<Imageview Android: Id = "@ + ID/three_image_one"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: Background = "@ drawable/icon"/>
<Imageview Android: Id = "@ + ID/three_image_two"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: Background = "@ drawable/icon"/>
<Imageview Android: Id = "@ + ID/three_image_three"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: Background = "@ drawable/icon"/>
</Linearlayout>
</Framelayout>