Android--Tabhost

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.