FragmentTabHost
2016-06-21 17:57
225 查看
xml布局文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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:orientation="vertical" > <FrameLayout android:id="@+id/realtabcontent" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1"/> <android.support.v4.app.FragmentTabHost android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@android:id/tabhost" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="0" /> </android.support.v4.app.FragmentTabHost> </LinearLayout>
代码:
FragmentTabHost tabHost= (FragmentTabHost) findViewById(android.R.id.tabhost);//找到fragmentTabHost tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);//setup for (int i=0;i<list.length;i++) { TabHost.TabSpec tabSpec =tabHost.newTabSpec("aa"+i+"bb").setIndicator(getview(i)); tabHost.addTab(tabSpec,list[i], null);//addtab } //获得tab布局
public View getview(int i){ View view = layoutInflater.inflate(R.layout.home_item, null); TextView textView = (TextView) view.findViewById(R.id.home_item_tv); textView.setText("aa"); return view; }
相关文章推荐
- FPGA频率测量算法
- “深入理解”—插入排序算法
- PHP发送POST请求的三种方式
- mysql之预处理语句prepare、execute、deallocate
- 玩转Java注释:自动调用监听器
- POJ 2761 Feed the dogs Treap+离散处理
- unbuntu配置tomcat的startup.sh文件
- Spring MVC 传入List参数的接收问题
- 替换rm命令防止误删除
- [**** _firstBaselineOffsetFromTop] **1683
- Glide的使用
- SuperSpider——打造功能强大的爬虫利器
- HTML5快速入门(三)—— 标签综合运用
- SuperSpider——打造功能强大的爬虫利器
- svn remains in tree-conflict
- 如何安装postman
- FFTW使用说明及实例调用
- noip2009-4 道路游戏
- 线程池的基本思想
- 如何成为一个web前端,怎样系统的去学习![A篇]