Android 自定义tabhost
来源:互联网 发布:2017中国云计算500强 编辑:程序博客网 时间:2024/05/18 05:56
不用继承TabActivity, 可以放置于界面中的任何位置,以下是具体的做法
xml 中的写法如下:
<TabHost android:id="@+id/TabHost01" android:layout_width="160px" android:layout_height="400px" android:layout_x="0px" android:layout_y="45px">
<LinearLayout android:layout_width="fill_parent"
android:orientation="vertical" android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="160px"
android:layout_height="80px" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:text="one"
android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:text="two"
android:id="@+id/TextView02" android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:text="three"
android:id="@+id/TextView03" android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
java 代码:
TabHost tabHost;
tabHost = (TabHost) this.findViewById(R.id.TabHost01);
tabHost.setup();
tabHost.addTab(tabHost.newTabSpec("tab_1")
.setContent(R.id.LinearLayout1)
.setIndicator("TAB1",
this.getResources().getDrawable(R.drawable.bar_unselected_3_1)));
tabHost.addTab(tabHost.newTabSpec("tab_2")
.setContent(R.id.LinearLayout2).setIndicator("TAB2",
this.getResources().getDrawable(R.drawable.bar_unselected_3_2)));
tabHost.addTab(tabHost.newTabSpec("tab_3")
.setContent(R.id.LinearLayout3).setIndicator("TAB3",
this.getResources().getDrawable(R.drawable.bar_unselected_3_3)));
tabHost.setCurrentTab(1);
原文链接
- android 自定义tabhost
- Android 自定义tabhost
- 【Android】自定义 Tabhost
- 【android开发】自定义TabHost
- android 自定义TabHost选择器
- Android 自定义Tabhost
- Android 自定义TabHost
- android自定义TabHost点击效果
- android tabHost选项卡自定义
- Android自定义控件之自定义tabhost
- android自定义TabHost扩展控件TabView
- android自定义TabHost扩展控件TabView
- 自定义Android TabHost的背景及文字
- android自定义TabHost扩展控件TabView
- 自定义TabHost
- 自定义TabHost
- 自定义TabHost
- 自定义TabHost
- C/C++源代码网
- Hacker Typer – 逼真黑客范儿
- 安装wi7的曲折
- 给电子类专业大一新生的十三条建议
- poj1566!!!
- Android 自定义tabhost
- MyEclipse:Available memory is low解决办法
- 优先队列实现Huffman树
- poj 1617
- Gallery Tutorials 详解
- 全局变量、静态全局变量、静态局部变量、局部变量
- iOS-利用本地数据来代替远程UIWebView请求
- C#中可选参数和命名参数的定义及使用
- nerver suppose that a point value is NULL or int value is 0 when defined a variant