首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

[Android 实例] 史下最全的Android的Tab与TabHost讲解 <转载>

2012-08-22 
[Android 实例] 史上最全的Android的Tab与TabHost讲解 转载这就是Tab,而盛放Tab的容器就是TabHost如何实

[Android 实例] 史上最全的Android的Tab与TabHost讲解 <转载>

这就是Tab,而盛放Tab的容器就是TabHost
如何实现??
每一个Tab还对应了一个布局,这个就有点好玩了。一个Activity,对应了多个功能布局。
①新建一个Tab项目,注意,不要生成main Activity
[Android 实例] 史下最全的Android的Tab与TabHost讲解 <转载>

<!--??这里是根节点布局??-- >
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:layout_width="fill_parent" android:layout_height="fill_parent">

<!--??第一个Tab 对应的布局??-- >
? ? <LinearLayout android:id="@+id/widget_layout_Blue"
? ?? ???android:layout_width="fill_parent" android:layout_height="fill_parent"
? ?? ???androidrientation="vertical" >
? ?? ???<EditText android:id="@+id/widget34" android:layout_width="fill_parent"
? ?? ?? ?? ?android:layout_height="wrap_content" android:text="EditText"
? ?? ?? ?? ?android:textSize="18sp">
? ?? ???</EditText>
? ?? ???<Button android:id="@+id/widget30" android:layout_width="wrap_content"
? ?? ?? ?? ?android:layout_height="wrap_content" android:text="Button">
? ?? ???</Button>
? ? </LinearLayout>
<!--??第二个Tab 对应的布局??-- >
? ? <LinearLayout android:id="@+id/widget_layout_red"
? ?? ???android:layout_width="fill_parent" android:layout_height="fill_parent"
? ?? ???androidrientation="vertical"??>
? ?? ???<AnalogClock android:id="@+id/widget36"
? ?? ?? ?? ?android:layout_width="wrap_content" android:layout_height="wrap_content">
? ?? ???</AnalogClock>
? ? </LinearLayout>
<!--??第三个Tab 对应的布局??-- >
? ? <LinearLayout android:id="@+id/widget_layout_green"
? ?? ???android:layout_width="fill_parent" android:layout_height="fill_parent"
? ?? ???androidrientation="vertical">
? ?? ???<RadioGroup android:id="@+id/widget43"
? ?? ?? ?? ?android:layout_width="166px" android:layout_height="98px"
? ?? ?? ?? ?androidrientation="vertical">
? ?? ?? ?? ?<RadioButton android:id="@+id/widget44"
? ?? ?? ?? ?? ? android:layout_width="wrap_content" android:layout_height="wrap_content"
? ?? ?? ?? ?? ? android:text="RadioButton">
? ?? ?? ?? ?</RadioButton>
? ?? ?? ?? ?<RadioButton android:id="@+id/widget45"
? ?? ?? ?? ?? ? android:layout_width="wrap_content" android:layout_height="wrap_content"
? ?? ?? ?? ?? ? android:text="RadioButton">
? ?? ?? ?? ?</RadioButton>
? ?? ???</RadioGroup>
? ? </LinearLayout>
</FrameLayout>复制代码

⑥首先,应该声明TabHost,然后用LayoutInflater过滤出布局来,给TabHost加上含有Tab页面的FrameLayout

2009-7-1 03:10:15 上传下载附件 (35.21 KB)

热点排行