修炼-------------Android TabHost,TabWidget选项卡总结 Android之TabHost TabHost,个人理解为选项卡的容器,是一种特殊的FrameLayout布局(帧布局) 根据SDK文档, Container for a tabbed window view
This object holds two children: a set of tab labels that the user clicks to select a specific tab, and a FrameLayout object that displays the contents of that page
The individual elements are typically controlled using this container object, rather than setting values on the child elements themselves
TabHost主要由两部分组成,标签和内容,其中内容是一个FrameLayout,当用户单击不同的标签可以显示不同的内容
使用标签可以达到分页的效果,是页面的内容更加丰富,更加具有亲和力,当然与此同时,也会增加页面的复杂程度
一个简单的TabHost布局 1
首先继承 TabActivity 2
通过 TabActivity的getTabHost()方法得到一个TabHost对象 3
定义选项卡的内容(是一个FrameLayout的对象),并与 TabHost绑定起来 可以通过一下语句绑定 TabHost容器的内容 LayoutInflater
from(this)
inflate(R
layout
main, tabHost
getTabContentView(), true