Android 31st Lesson--tabhost

Source: Internet
Author: User

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

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.