Tabhost is also equivalent to the option box under Windows
There are two ways to implement
1. Inherit tabactivity (deprecated): Get tabhost from tabactivity using the Gettabhost () method
2. Tabhost is defined in the layout file, but the ID of the tabwidget must be @android:id/tabs,framelayout ID must be @android:id/tabcontent.
The main introduction to the second method is the use of
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"Android:id= "@+id/hometabs"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Vertical" > <tabhost Android:id= "@+id/tabhost"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content" > <LinearLayout android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Vertical" > <Tabwidget Android:id= "@android: Id/tabs"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:orientation= "Horizontal" > </TabWidget> <framelayout Android:id= "@android: Id/tabcontent"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" > <TextView Android:id= "@+id/text"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:text= "first option box"/> <TextView Android:id= "@+id/photo"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:text= "second option box"/> <TextView Android:id= "@+id/video"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:text= "third option box"/> <TextView Android:id= "@+id/movie"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:text= "I am a movie"/> </FrameLayout> </LinearLayout> </TabHost></LinearLayout>
Layout
Android--Tabhost