Android 之 TabHost 分页面板控件
来源:互联网 发布:人工智能机器人哪里买 编辑:程序博客网 时间:2024/05/29 13:32
TabHost跟windows上的Tab标签是一样的, 在安卓中也是可以用一个Activity来存放多个页面, 用Tab来达到切换效果。
xml 文件
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost"
>
//TAB1的布局控件
<LinearLayout
android:id="@+id/Tab1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是tab1"
/>
</LinearLayout>
//TAB2的布局控件
<LinearLayout
android:id="@+id/Tab2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是tab2"
/>
</LinearLayout>
</FrameLayout>
java代码
public class MissedHelperActivity extends TabActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TabHost tabs = getTabHost(); //得到TAB对象
LayoutInflater.from(this).inflate(R.layout.main, tabs.getTabContentView(), true); //载入布局
//添加第一个Tab标签
TabSpec tab1 = tabs.newTabSpec("tab1");
tab1.setIndicator("tab1");
tab1.setContent(R.id.Tab1);
tabs.addTab(tab1);
//添加第二个 Tab标签
TabSpec tab2 = tabs.newTabSpec("tab2");
tab2.setIndicator("tab2");
tab2.setContent(R.id.Tab2);
tabs.addTab(tab2);
}
}
- Android 之 TabHost 分页面板控件
- android控件之TabHost
- Android控件之TabHost
- Android控件之TabHost
- Android控件之TabHost
- Android控件之TabHost探究
- Android控件之TabHost探究
- android控件之tabhost tabwedget
- Android控件开发之TabHost
- J2SE分页面板控件
- Android开发之TabHost控件的使用
- Android 控件之TabHost Tab页
- Android 控件之TabHost Tab页
- Android控件之TabHost 转载篇
- Android 控件之TabHost Tab页
- Android自定义控件之自定义tabhost
- android 学习笔记6——分页标签之TabHost
- Android基础-TabHost控件
- 在VC++中用ODBC访问SQL Server数据库
- 深入浅出之正则表达式(一)
- 深入浅出之正则表达式(二)
- 杰表推出PDF417 在线演示,可生成html代码
- permission uses-permission区别
- Android 之 TabHost 分页面板控件
- Linux中LoadLibrary()函数(zhuan)
- 完成端口(CompletionPort)详解 - 手把手教你玩转网络编程系列之三
- 在ie上使用xpath时selenium运行缓慢的解决办法
- shell中的引号
- Linux多线程及临界区编程例解
- 用Eclipse CDT + CMake构建跨平台工程(VC/GCC)
- oracle10g用户system以sysdba身份无法登录处理办法
- 存在与时间的初级思考