Android的TabHost组件-android的学习之旅(四十)
来源:互联网 发布:unity3d源码下载 编辑:程序博客网 时间:2024/06/06 01:07
TabHost简介
虽然,官方建议用Fagment取代TabHost,但是我们还是大概的介绍一下。TabHost是一种非常简单的组件,TabHost可以很方便的在窗口放置多个标签页,每一个标签页相当于获得了一个摆放位置。
注意
TabHost的内部需要两个组件一个是TabWidget和FrameLayout两个组件。
通话记录界面
<?xml version="1.0" encoding="utf-8"?><TabHost xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"android:layout_height="match_parent" android:layout_weight="1" android:id="@android:id/tabhost" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TabWidget android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@android:id/tabs"/> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/tabcontent"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/tab01"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/tab02"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/tab03"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="hello"/> </LinearLayout> </FrameLayout> </LinearLayout></TabHost>
package peng.liu.test;import android.app.TabActivity;import android.os.Bundle;import android.widget.TabHost;public class MainActivity extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TabHost tabHost = getTabHost(); TabHost.TabSpec tabSpec = tabHost.newTabSpec("tab01").setIndicator("已接电话").setContent(R.id.tab01); tabHost.addTab(tabSpec); TabHost.TabSpec tabSpec1 = tabHost.newTabSpec("tab02").setIndicator("呼叫电话").setContent(R.id.tab02); TabHost.TabSpec tabSpec2 = tabHost.newTabSpec("tab03").setIndicator("未接电话").setContent(R.id.tab03); tabHost.addTab(tabSpec1); tabHost.addTab(tabSpec2); }}
效果图
0 0
- Android的TabHost组件-android的学习之旅(四十)
- Android组件的使用:TabHost
- Android的actionBar的菜单使用-android学习之旅(四十三)
- Android的PopupWindow使用android学习之旅(四十三)
- Activity之间的数据传递-android学习之旅(四十七)
- Android之TabHost组件美化
- android组件之TabHost用法
- Android的UI组件之TabHost(选项卡)的功能和用法
- Android TabHost的学习笔记
- android之tab(tabHost)的样式
- Android之TabHost的创建
- android学习之-TabHost
- Android学习之TabHost
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Codeforces Round #306 (Div. 2) A
- Android Studio快捷键
- [hdu]Tempter of the Bone
- HDU 不容易系列之(3)—— LELE的RPG难题
- OpenStack行业实践和发展趋势
- Android的TabHost组件-android的学习之旅(四十)
- Odroid U3 烧写镜像文件
- CCNA学习指南 IP路由
- VNR共享辞书中翻译的转码和代理
- ActionScript 3.0 学习(二) Flash Builder找不到所需版本的Adobe Flash Player
- java内置数据结构--Map接口与特性
- 处理数据库Null值
- LINKIT assist学习笔记2--安装Linkit assist相关开发平台
- Android学习日记(3)