Android Learning notes:tabhost and FragmentTabHostTabHost namespaces: android.widget.TabHost initialization function (must be called before AddTab): setup (); contains two child elements: 1.tab label Container tabwidget (@android: Id/tabs) 2. Tab content Container Framelayout (@android: id/tabcontent) fragmenttabhost namespace: 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) &nbsP; 2.tab content Container framelayout [width 0DP] (@android: id/tabcontent) 3.tab content Container framelayout [real container] (@+id/realtabcontent) Question: Why tabcontent exist at the same time and RealTabContent two x framelayout? Answer: "About fragmenttabhost in Tabwidget can't move to the bottom of the screen bug" http:// blog.csdn.net/wklbeta/article/details/11329207: "Android Development: Using fragment to transform Tabactivity" http://www.blogjava.net/amplifier/archive/2012/12/27/393409.html Experience - Several ways to implement the TAB function: 1. (obsolete) inherit from tabactivity + tabhost layout + Activity content 1.1:tabactivity for activitygroup[in version 13] sub-category 1.2: Use Gettabhost () Get tabhost object 1.3: Use newtabspec (...). SetContent (Intent) Add tab tag and content 2. (obsolete) inherit from activitygroup + tabhost Layout + Activity Content 2.1:activitygroup was abandoned in version 13 2.2: Use findviewbyid to get tabhost objects 2.3: Using Setup (new Localactivitymanager (this, true)) Initialize 2.4: Use newtabspec (...). SetContent (Intent) Add tab tag and Content 3. (simple) inherit from fragmentactivity + FragmentTabHost Layout + Fragment Content 3.1: Using findviewbyid Get fragmenttabhost Objects 3.2: Initializing Using Setup (This, getsupportfragmentmanager (), r.id.realtabcontent) 3.3: Use AddTab (NewTabSpec (). Setindicator (), fragment.class, null) Add tab tag and content 4. (complex) inherit from fragmentactivity + tabhost layout + viewpager layout + Fragment content 4.1: Using Findviewbyid Get tabhost Objects 4.2: Using Setup () initialization 4.3: Using Tabhost.addtab (tabspEc.setcontent (Dummytabfactory)); Add tab tags and empty content 4.4: Controlling the actual display of Viewpager in tabhost.ontabchanged 4.5: Controls 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. such as : The tab tag is fixed and has its own set of display effects, so there is no need to tabhost the layout at all. 5. (DIY) inherit from fragmentactivity + custom layouts + Viewpager Layout + Fragment Content 5.1: Embed fixed tab elements in custom layouts 5.2: Controlling vie in the tag element click eventActual display of Wpager 5.3: Controls the selection of the label elements in the viewpager.onpageselected when sliding.
Android Learning notes: Tabhost and Fragmenttabhost