[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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.