TabhostNamespace: 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)Questions:Why 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 function:1. (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 content 3.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 and Empty Content 4.4: Control the actual display of Viewpager in tabhost.ontabchanged 4.5: sliding in viewpager.onpageselected Controls the Tab tab selection. 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 content 5.1: Custom layout embedded in solid TAB TAB ELEMENT 5.2: Controls the actual display of Viewpager in the tag element Click event 5.3: Controls the selection of the label element in viewpager.onpageselected when sliding.
By:asiontang
at:2013 September 27 10:29:08
Asion Tang Source: http://asiontang.cnblogs.com
Go Android Learning notes: Tabhost and Fragmenttabhost