当前位置:网站首页>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推出Web3游戏“Satorspace” ,并上线Huobi
- [image sensor] correlated double sampling CDs
- PLC:自动纠正数据集噪声,来洗洗数据集吧 | ICLR 2021 Spotlight
- DNS series (I): why does the updated DNS record not take effect?
- A tour of grpc:03 - proto serialization / deserialization
- [Seaborn] combination chart: pairplot and jointplot
- 【信息安全法律法规】复习篇
- 数值 - number(Lua)
- Flask搭建api服务-生成API文档
- 企业即时通讯软件是什么?它有哪些优势呢?
猜你喜欢
Sator a lancé le jeu web 3 "satorspace" et a lancé huobi
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
Share the latest high-frequency Android interview questions, and take you to explore the Android event distribution mechanism
《世界粮食安全和营养状况》报告发布:2021年全球饥饿人口增至8.28亿
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
SlashData开发者工具榜首等你而定!!!
命令模式 - Unity
【TPM2.0原理及应用指南】 16、17、18章
网络攻防复习篇
第3章业务功能开发(用户登录)
随机推荐
Matplotlib绘图界面设置
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
Flask搭建api服务-SQL配置文件
麒麟信安中标国网新一代调度项目!
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
On Apache Doris Fe processing query SQL source code analysis
【源码解读】| LiveListenerBus源码解读
网络攻防复习篇
【网络攻防原理与技术】第6章:特洛伊木马
数值 - number(Lua)
mysql官网下载:Linux的mysql8.x版本(图文详解)
Matplotlib绘制三维图形
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
LeetCode刷题day49
Repair method of firewall system crash and file loss, material cost 0 yuan
Blue Bridge Cup final XOR conversion 100 points
【TPM2.0原理及应用指南】 12、13、14章
本周小贴士#135:测试约定而不是实现
[source code interpretation] | source code interpretation of livelistenerbus
First in China! Todesk integrates RTC technology into remote desktop, with clearer image quality and smoother operation