tabhost 垂直布局
来源:互联网 发布:计算机初级程序员考试 编辑:程序博客网 时间:2024/05/16 01:46
// 创建一个视图,tabwidget视图
private View createIndicatorView(Context context, TabHost tabHost, String title) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View tabIndicator = inflater.inflate(R.layout.tab_indicator_vertical, tabHost.getTabWidget(), false);
final TextView titleView = (TextView) tabIndicator.findViewById(R.id.tv_indicator);
titleView.setText(title);
return tabIndicator;
}
//oncreate方法
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tabhost);
//获取tabhost对象
TabHost tabHost = this.getTabHost();
//获取tabwidget对象,并且设置布局方式为垂直布局
tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL);
//创建并添加tabspec对象到tabhost中
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator(createIndicatorView(this, tabHost, "拜访工作")).setContent(new Intent(this, BrandActivity.class)));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator(createIndicatorView(this, tabHost, "视察工作")).setContent(new Intent(this, BrandActivity.class)));
tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator(createIndicatorView(this, tabHost, "总结工作")).setContent(new Intent(this, BrandActivity.class)));
}
main.xml文件
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>
tab_indicator_vertical.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_indicator"
android:padding="30dp"
android:textSize="40sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
- tabhost 垂直布局
- TabHost布局
- Android TabHost布局
- Android之TabHost布局
- Android之TabHost布局
- android tabHost布局 大全
- TabHost布局需注意
- Android之TabHost布局
- Android之TabHost布局
- Anroid下TabHost布局
- Android之TabHost布局
- Android之TabHost布局
- Android之TabHost布局
- Android之TabHost布局
- Android之TabHost布局
- Android之TabHost布局
- Android之TabHost布局
- Android之tabhost布局
- flex3.6入门学习笔记之八 Alert的3种应用
- 使用wabacus框架实现多个数据源集合到一个报表上中的做法
- jQuery学习总结(四)
- Oracle分页查询格式
- 树形控件的使用
- tabhost 垂直布局
- PL SQL下通过语句查看表或者视图结构
- 经典:从追MM谈Java的23种设计模式
- MySQL 的并集、交集和差集
- Visual Leak Detector 2.2.3 Visual C++内存检测工具
- 头文件的编写
- mysql 根据字段名查找该字段属于哪个表
- 使用 Struts 2 开发 RESTful 服务
- 在jsp中修改了编码方式出现了乱码怎么办