TabHost,标签页的使用
2016-06-24 12:18
316 查看
转载于: http://blog.csdn.net/shulianghan/article/details/18233209
a13f
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?> <TabHost android:id="@android:id/tabhost" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"/> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <RelativeLayout android:id="@+id/tab01" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:gravity="center" android:textSize="23sp" android:layout_width="match_parent" android:layout_height="match_parent" android:text="text01"/> </RelativeLayout> <RelativeLayout android:id="@+id/tab02" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:gravity="center" android:textSize="23sp" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" android:text="text02"/> </RelativeLayout> <RelativeLayout android:id="@+id/tab03" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:gravity="center" android:textSize="23sp" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" android:text="text03"/> </RelativeLayout> </FrameLayout> </LinearLayout> </TabHost> </span>
<span style="font-size:18px;"> </span>
<span style="font-size:18px;"> </span>
<span style="font-size:18px;"> </span>
<pre name="code" class="java"><span style="font-size:18px;">import android.app.TabActivity; import android.os.Bundle; import android.widget.TabHost; public class MainActivity extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TabHost tabhost = getTabHost(); TabHost.TabSpec page1 = tabhost.newTabSpec("tab1").setIndicator("第一页").setContent(R.id.tab01); tabhost.addTab(page1); TabHost.TabSpec page2 = tabhost.newTabSpec("tab2").setIndicator("第二页").setContent(R.id.tab02); tabhost.addTab(page2); TabHost.TabSpec page3 = tabhost.newTabSpec("tab3").setIndicator("第三页").setContent(R.id.tab03); tabhost.addTab(page3); } } </span>
a13f
相关文章推荐
- Hbuilder中百度地图插件的使用
- String.replaceAll()
- NYOJ 108 士兵杀敌(一)
- 用JSON-server模拟REST API(一) 安装运行
- I.MX6 U-boot imxotp MAC address 写入
- 设置动画
- ReactiveCocoa进阶
- this的面面观
- 暑期集训盲打首秀
- 第14周项目三—数组类模板
- Fatal error: Call-time pass-by-reference has been removed
- 求一个二维数组中每列的最小值
- java基础之LinkedList练习--模拟堆栈
- WPF 4 媒体播放器(MediaElement)
- Android viewpager实现无限循环轮播
- 第十四周项目二两个成员的类模板二
- Spring线程池
- 转: Android 后台任务型App多进程架构演化
- 指示器随机变量,算法导论5.2
- Java设计模式之--访问者模式(Visitor)