Although this component has not been recommended, but I still study a bit. His XML is a little complicated.
<Tabhostxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:id= "@android: Id/tabhost"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:layout_weight= "1" > <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" > <TabwidgetAndroid:id= "@android: Id/tabs"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content" /> <FramelayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:id= "@android: Id/tabcontent"> <LinearLayoutAndroid:id= "@+id/tab01"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" > <TextViewAndroid:id= "@+id/tv1"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:text= "Noor Nurhachi" /> </LinearLayout> <LinearLayoutAndroid:id= "@+id/tab02"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" > <TextViewAndroid:id= "@+id/tv2"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:text= "Noor Nurhachi" /> </LinearLayout> <LinearLayoutAndroid:id= "@+id/tab03"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" > <TextViewAndroid:id= "@+id/tv3"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:text= "Noor Nurhachi" /> </LinearLayout> </Framelayout> </LinearLayout></Tabhost>
I think it's all about tabhost, and then using the Tabwidget in the label section, the page is framelayout. Inside each label content is wrapped with linearlayout
PackageCom.example.tabhost;Importandroid.app.TabActivity;ImportAndroid.os.Bundle;ImportAndroid.widget.TabHost;ImportAndroid.widget.TabHost.TabSpec; @SuppressWarnings ("Deprecation") Public classMainactivityextendstabactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Tabhost Tabhost=Gettabhost (); Tabspec TAB1=tabhost.newtabspec ("Tab1"). Setindicator ("answered Phone"). SetContent (R.ID.TAB01); Tabhost.addtab (TAB1); Tabspec tab2=tabhost.newtabspec ("TaB2"). Setindicator ("Outgoing call"), Getresources (). getdrawable (R.drawable.ic_launcher)). SetContent (R.ID.TAB02); Tabhost.addtab (TAB2); Tabspec tab3=tabhost.newtabspec ("Tab3"). Setindicator ("Missed Call"). SetContent (R.ID.TAB03); Tabhost.addtab (TAB3); }}
Android 31st Lesson--tabhost