[Android ask me] How to Use the selected video card-tabhost

Source: Internet
Author: User

1. Example description

    • Tabhost is a view container component provided by the Android system. It can display a group of child components by pageProgramMultiple activities are organized. To create a tabhost, you also need to introduce the tabwidget component and the tabhost. tabspec component. tabwidget represents the position of the tab, and tabhost. spec represents the content of each tab.
    • In the layout file of this example, the ID of tabwidget must be set to "@ Android: ID/tabs", and the ID of framelayout must be set to "@ Android: ID/tabcontent ". In addition, if mainactivity does not inherit from tabactivityCodeIn, after you find the tabhost using the findviewbyid () method, you should first execute the setup () method to load the tabhost. If mainactivity inherits from tabactivity, the tabhost ID must be set to @ Android: ID/tabhost"

 

 

2. Running result

3. Core code

 

@ Overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); resources res = getresources (); tabhost host = (tabhost) findviewbyid (R. id. tabhost); host. setup (); tabspec spec; spec = partition 1); host. addtab (SPEC); spec = partition 2); host. addtab (SPEC); spec = partition 3); host. addtab (SPEC); host. setcurrenttab (1); host. setontabchangedlistener (New ontabchangelistener () {@ overridepublic void ontabchanged (string Tabid) {toast. maketext (mainactivity. this, Tabid, toast. length_short ). show ();}});
}

 

5. Video Explanation

Http://www.eyeandroid.com/thread-11497-1-1.html

Related Article

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.