Android Tabhost Components-android learning Journey (40)

Source: Internet
Author: User

Tabhost Introduction

Although the official proposal is to replace tabhost with Fagment, we would like to introduce. Tabhost is a very simple component, tabhost can be conveniently placed in the window multiple tabs, each tab equivalent to get a placement.

Attention

The interior of the tabhost requires two components, one of which is tabwidget and framelayout two components.

Call History Interface
<?xml version= "1.0" encoding= "Utf-8"?><tabhost  xmlns:android  = "http://schemas.android.com/apk/res/android"  xmlns:tools  = "Http://schemas.android.com/tools"  android:layout_width  = "match_parent"  android:layout_height  = "match_parent"  android:layout_weight  = "1"  android:id  = "@android: Id/tabhost"  >     <linearlayoutandroid:layout_width="Wrap_content"android:layout_height ="Wrap_content"android:orientation="vertical">                                <tabwidgetandroid:layout_width="Match_parent"android:layout_height ="Wrap_content"android:id="@android: Id/tabs"/>                                            <framelayoutandroid:layout_width="Match_parent"android:layout_height ="Match_parent"android:id="@android: Id/tabcontent">                                                <linearlayoutandroid:layout_width="Fill_parent"android:layout_ Height="Fill_parent"android:orientation="vertical"android:id ="@+id/tab01">                                                                                <TextViewandroid:layout_width="Match_parent"android:layout_height= "Wrap_content" Android:text="Hello"/>                                                                            <TextViewandroid:layout_width="Match_parent"android:layout_height ="Wrap_content"android:text="Hello"/>                                                                            </linearlayout>            <linearlayoutandroid:layout_width="Fill_parent"android:layout_height ="Fill_parent"android:orientation="vertical"android:id="@+id/ TAB02 ">                                                                                <TextViewandroid:layout_width="Match_parent"android:layout_ Height="Wrap_content"android:text="Hello"/>                                                                            <TextViewandroid:layout_width="Match_parent"android:layout_height= "Wrap_content" Android:text="Hello"/>                                                                        </linearlayout>            <linearlayoutandroid:layout_width="Fill_parent"android:layout_height ="Fill_parent"android:orientation="vertical"android:id="@+id/ Tab03 ">                                                                                <TextViewandroid:layout_width="Match_parent"android:layout_ Height="Wrap_content"android:text="Hello"/>                                                                            <TextViewandroid:layout_width="Match_parent"android:layout_height= "Wrap_content" Android:text="Hello"/>                                                                        </linearlayout>            </framelayout>        </linearlayout></tabhost>
Package Peng. Liu. Test;Import Android. App. Tabactivity;Import Android. OS. Bundle;Import Android. Widgets. Tabhost;public class Mainactivity extends tabactivity {@Override protected void onCreate (Bundle savedinstancestate) { Super. OnCreate(savedinstancestate);Setcontentview (R. Layout. Activity_main);Tabhost tabhost = Gettabhost ();Tabhost. TabspecTabspec = Tabhost. Newtabspec("TAB01"). Setindicator("answered phone"). SetContent(R. ID. Tab01);Tabhost. AddTab(TABSPEC);Tabhost. TabspecTABSPEC1 = Tabhost. Newtabspec("TAB02"). Setindicator("Call phone"). SetContent(R. ID. Tab12H;Tabhost. TabspecTABSPEC2 = Tabhost. Newtabspec("TAB03"). Setindicator("Missed Call"). SetContent(R. ID. Tab03);Tabhost. AddTab(TABSPEC1);Tabhost. AddTab(TABSPEC2);}}

Android Tabhost Components-android learning Journey (40)

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.