当前位置:网站首页>TabHOST 选项卡的功能和用法
TabHOST 选项卡的功能和用法
2022-07-07 15:40:00 【XLMN】
TabHOST
选项卡的功能和用法
tabhost可以方便的在窗口放置多个标签页,,每个标签页相当于一个和外部容器一样大小的组件摆放区域,通过这种方式,就可以在一个容器中放置更多组件
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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="match_parent"
android:layout_height="match_parent"
android:id="@+id/tb01"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="公共课总分"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="专业课总分"/>
</LinearLayout>
<!--定义第二个标签页-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tb02"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="总分合计"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="总分合计01"/>
</LinearLayout>
<!--定义第三个标签页-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tb03"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="录取学校"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="录取专业"/>
</LinearLayout>
</FrameLayout>
public class MainActivity extends TabActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tabhost); //获取改activity里面,tabhost组件 TabHost th = getTabHost(); //创建第一个tab页面 TabHost.TabSpec tab1 = th.newTabSpec("tab1").setIndicator("分数").setContent(R.id.tb01); //添加第一个标签页 th.addTab(tab1); TabHost.TabSpec tab2 = th.newTabSpec("tab2") //在标签标题上面放置图标 .setIndicator("总分合计", getResources().getDrawable(R.drawable.mia5)) .setContent(R.id.tb02); //添加第二个标签页 th.addTab(tab2); TabHost.TabSpec tab3 = th.newTabSpec("tab3") .setIndicator("录取专业") .setContent(R.id.tb03); //添加第三个标签页 th.addTab(tab3); }
}

边栏推荐
- Sator launched Web3 game "satorspace" and launched hoobi
- L1-028 判断素数(Lua)
- 【TPM2.0原理及应用指南】 12、13、14章
- 【网络攻防原理与技术】第6章:特洛伊木马
- LeetCode 1981. Minimize the difference between the target value and the selected element one question per day
- 【可信计算】第十三次课:TPM扩展授权与密钥管理
- 麒麟信安加入宁夏商用密码协会
- Repair method of firewall system crash and file loss, material cost 0 yuan
- 【信息安全法律法規】複習篇
- 如何在博客中添加Aplayer音乐播放器
猜你喜欢
随机推荐
【网络攻防原理与技术】第7章:口令攻击技术 第8章:网络监听技术
Rpcms method of obtaining articles under the specified classification
【TPM2.0原理及应用指南】 1-3章
Blue Bridge Cup final XOR conversion 100 points
【源码解读】| LiveListenerBus源码解读
浅谈 Apache Doris FE 处理查询 SQL 源码解析
[Seaborn] combination chart: facetgrid, jointgrid, pairgrid
DevOps 的运营和商业利益指南
redis主从、哨兵主备切换搭建一步一步图解实现
企业即时通讯软件是什么?它有哪些优势呢?
【网络攻防原理与技术】第4章:网络扫描技术
mysql实现两个字段合并成一个字段查询
邮件服务器被列入黑名单,如何快速解封?
跟奥巴马一起画方块(Lua)
本周小贴士#135:测试约定而不是实现
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
专精特新软件开发类企业实力指数发布,麒麟信安荣誉登榜
Notes on installing MySQL in centos7
【TPM2.0原理及应用指南】 5、7、8章
【可信计算】第十次课:TPM密码资源管理(二)









