Android Study Notes (30): tab TabHost Analysis
The TabHost component is a container that can store multiple tabs on the interface. The tab size is the same as that of the external container.
The TabWidget component is the title bar of TabHost. You can click the tab to switch.
The TabSpec component is a Tab ).
Use TabHost as follows:
1. Define a TabHost component in the XML file and define a FrameLayout. Add content to it.
2. The Activity should inherit from TabActivity.
3. Call the getTabHost () method of TabActivity to obtain the TabHost object.
4. Create and add tabs using the TabHost object method:
NewTabSpec (Stringtag): Create a tab
AddTab (TabHost. TabSpectabSpec): Add a tab
In the layout file, several controls must reference the existing Android system IDs and cannot be defined by themselves:
TabHost: @ android: id/tabhost
TabWidget: @ android: id/tabs
FrameLayout: @ android: id/tabcontent
When the tab of TabHost changes, you can use OnTabChangeListener to bind event listening to it.
TabSpec can use the setContent (intviewId) and setContent (Intentintent) Methods to set the tab content, that is, TabSpec can directly reprint another Activity.