Android Learning notes: Tabhost and Fragmenttabhost

Source: Internet
Author: User

Namespace: Android.widget.TabHost initialization function (must be called before AddTab): Setup (); Contains two sub-elements: 1.Tab label container tabwidget (@android: id/tabs) 2.Tab content container Framelayout (@android: id/tabcontent)FragmenttabhostNamespace: Android.support.v4.app.FragmentTabHost android.support.v13.app.FragmentTabHost initialization function (must be called before AddTab)    : Setup (this, Getsupportfragmentmanager (), r.id.realtabcontent);        Contains three sub-elements: 1.Tab label container tabwidget (@android: id/tabs) 2.Tab content Container Framelayout [w/h 0DP] (@android: id/tabcontent) 3.Tab content Container framelayout [real container] (@+id/realtabcontent)QuestionsWhy are there tabcontent and realtabcontent two framelayout at the same time? FAQ: "Tabwidget can't move to the bottom of the screen in Fragmenttabhost" http://blog.csdn.net/wklbeta/article/details/11329207Information: "Android Development: Using fragment to transform Tabactivity" http://www.blogjava.net/amplifier/archive/2012/12/27/393409.htmlExperience-several ways to implement the TAB function1. (obsolete) inherit from tabactivity + tabhost layout + Activity content1.1:tabactivity for activitygroup[in version 13] Subclass 1.2: Using Gettabhost () to get Tabhost Object 1.3: Using Newtabspec (...). SetContent (Intent) Add tab tags and content2. (obsolete) inherit from Activitygroup + tabhost layout + Activity content2.1:activitygroup was abandoned in version 13 2.2: Using Findviewbyid to get Tabhost object 2.3: Using Setup (New Localactivitymana GER (this, true)) initialization 2.4: Use Newtabspec (...). SetContent (Intent) Add tab tags and content3. (simple) inherit from fragmentactivity + fragmenttabhost layout + Fragment content3.1: Get Fragmenttabhost object using Findviewbyid 3.2: Using Setup (this, Getsupportfragmentmanager (), r.id.realtabcontent) Initialization 3.3: Use AddTab (Newtabspec (). Setindicator (), fragment.class, NULL) to add tab tags and content4. (complex) inherit from fragmentactivity + tabhost layout + viewpager layout + Fragment content4.1: Using Findviewbyid to get Tabhost object 4.2: Using setup () initialization 4.3: Using Tabhost.addtab (Tabspec.setcontent (Dum Mytabfactory)); Add tab tags andEmpty Content4.4: Control Viewpager's actual display in tabhost.ontabchanged 4.5: Control tab TAB Selection in viewpager.onpageselected when sliding.PS: The Tabhost layout here is somewhat superfluous when the number of tabs is fixed and the label effect is not pursued and the system remains consistent. For example, if the tab tag is fixed for a particular application and has its own set of display effects, there is no need to tabhost the layout at all. 5. (DIY) inherit from fragmentactivity + custom layout + viewpager layout + Fragment content5.1: Embed fixed tab element in custom layout 5.2: Control the actual display of Viewpager in the tag element Click event 5.3: Control the tag element in viewpager.onpageselected when sliding The choice of the vegetarian.

Http://www.cnblogs.com/asion/archive/2013/09/25/3339313.html

Android Learning notes: Tabhost and Fragmenttabhost

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.