当前位置:网站首页>Functions and usage of tabhost tab
Functions and usage of tabhost tab
2022-07-07 17:37:00 【XLMN】
TabHOST
Functions and usage of tabs
tabhost You can easily place multiple tabs in the window ,, Each tab is equivalent to a component placement area the same size as the external container , In this way , You can put more components in one container
<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">
<!-- Define the content of the first tab -->
<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=" Total score of public courses "/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" The total score of professional courses "/>
</LinearLayout>
<!-- Define the second tab -->
<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=" Total score "/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" Total score 01"/>
</LinearLayout>
<!-- Define the third tab -->
<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=" Admission to school "/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" Admission major "/>
</LinearLayout>
</FrameLayout>
public class MainActivity extends TabActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tabhost); // Get change activity Inside ,tabhost Components TabHost th = getTabHost(); // Create the first one tab page TabHost.TabSpec tab1 = th.newTabSpec("tab1").setIndicator(" fraction ").setContent(R.id.tb01); // Add the first tab th.addTab(tab1); TabHost.TabSpec tab2 = th.newTabSpec("tab2") // Place the icon above the label Title .setIndicator(" Total score ", getResources().getDrawable(R.drawable.mia5)) .setContent(R.id.tb02); // Add a second tab th.addTab(tab2); TabHost.TabSpec tab3 = th.newTabSpec("tab3") .setIndicator(" Admission major ") .setContent(R.id.tb03); // Add a third tab th.addTab(tab3); }
}

边栏推荐
猜你喜欢
随机推荐
[source code interpretation] | source code interpretation of livelistenerbus
Functions and usage of imageswitch
[fan Tan] after the arrival of Web3.0, where should testers go? (ten predictions and suggestions)
DNS 系列(一):为什么更新了 DNS 记录不生效?
【网络攻防原理与技术】第5章:拒绝服务攻击
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
calendarview日历视图组件的功能和用法
Lex & yacc of Pisa proxy SQL parsing
专精特新软件开发类企业实力指数发布,麒麟信安荣誉登榜
数值 - number(Lua)
Matplotlib绘图界面设置
【TPM2.0原理及应用指南】 1-3章
Solidity 开发环境搭建
The top of slashdata developer tool is up to you!!!
VSCode关于C语言的3个配置文件
Mysql 索引命中级别分析
Repair method of firewall system crash and file loss, material cost 0 yuan
鲲鹏开发者峰会2022 | 麒麟信安携手鲲鹏共筑计算产业新生态
Sator launched Web3 game "satorspace" and launched hoobi
Functions and usage of viewflipper









