当前位置:网站首页>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); }
}
边栏推荐
- Lex & yacc of Pisa proxy SQL parsing
- Smart logistics platform: make overseas warehouses smarter
- Matplotlib绘制三维图形
- MySQL usage notes 1
- 管理VDI的几个最佳实践
- SlashData开发者工具榜首等你而定!!!
- Test case management tool recommendation
- 到底有多二(Lua)
- DNS 系列(一):为什么更新了 DNS 记录不生效?
- First in China! Todesk integrates RTC technology into remote desktop, with clearer image quality and smoother operation
猜你喜欢
随机推荐
Matplotlib绘图界面设置
Devops' operational and commercial benefits Guide
[Huang ah code] Why do I suggest you choose go instead of PHP?
麒麟信安中标国网新一代调度项目!
第1章CRM核心业务介绍
【TPM2.0原理及应用指南】 1-3章
Seaborn data visualization
本周小贴士#140:常量:安全习语
麒麟信安加入宁夏商用密码协会
First in China! Todesk integrates RTC technology into remote desktop, with clearer image quality and smoother operation
LeetCode1051(C#)
Skimage learning (2) -- RGB to grayscale, RGB to HSV, histogram matching
第2章搭建CRM项目开发环境(数据库设计)
LeetCode刷题day49
Enum + Validation 的个人最佳实践 demo 分享
大笨钟(Lua)
【饭谈】如何设计好一款测试平台?
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
[fan Tan] after the arrival of Web3.0, where should testers go? (ten predictions and suggestions)
Sator推出Web3遊戲“Satorspace” ,並上線Huobi