- 浏览: 628022 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
luo_ganlin:
别的不多说,点个赞!
关于Android隐式启动Activity -
IWSo:
谢楼主!研究了好久,原来是这样!
android中如何让LinearLayout实现点击时背景图片切换 -
fantao005x:
粘帖的不错
android中如何让listview的内容全部显示出来 -
learner576539763:
Android_gqs 写道请问博主,Viewstub 可实现 ...
android中ViewStub使用 -
goontosoon:
抄的什么啊,狗屁不通
对ContentProvider中getType(Uri uri)
tabHost往往被当作程序的通用框架入口,其主要的使用方式有两种: 1.继承TabActivity,结合对应的xml配置文件导入tab选项内容体 2.继承Activity,结合拥有TabHost标签的xml配置文件导入
对于1:
public class TabExdHostActivity extends TabActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TabHost myTabHost = this.getTabHost(); LayoutInflater.from(this).inflate(R.layout.exmain, myTabHost.getTabContentView(), true); myTabHost.addTab(myTabHost.newTabSpec("选项卡1").setIndicator("选项卡1").setContent(R.id.tab1)); myTabHost.addTab(myTabHost.newTabSpec("选项卡2").setIndicator("选项卡2").setContent(R.id.tab2)); myTabHost.addTab(myTabHost.newTabSpec("选项卡3").setIndicator("选项卡3").setContent(R.id.tab3)); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_1" /> </LinearLayout> <LinearLayout android:id="@+id/tab2" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/view2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_2" /> </LinearLayout> <LinearLayout android:id="@+id/tab3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_3" /> </LinearLayout> <LinearLayout android:id="@+id/tab4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_4" /> </LinearLayout> </LinearLayout>
对于2:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tabhost = (TabHost) findViewById(R.id.tabhost); tabhost.setup(); TabHost.TabSpec spec = tabhost.newTabSpec("tab1"); spec.setContent(R.id.tab1); spec.setIndicator("主页"); tabhost.addTab(spec); TabHost.TabSpec spec2 = tabhost.newTabSpec("tab2"); spec2.setContent(R.id.tab2); spec2.setIndicator("主页2"); tabhost.addTab(spec2); TabHost.TabSpec spec3 = tabhost.newTabSpec("tab3"); spec3.setContent(R.id.tab3); spec3.setIndicator("主页3"); tabhost.addTab(spec3); TabHost.TabSpec spec4 = tabhost.newTabSpec("tab4"); spec4.setContent(R.id.tab4); spec4.setIndicator("主页4"); tabhost.addTab(spec4); tabhost.setOnTabChangedListener(this); bt_cg = (Button) findViewById(R.id.bt_cg); bt_cg.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(TabHostActivity.this, TabExdHostActivity.class); startActivity(intent); } }); }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabHost android:id="@+id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="match_parent" android:orientation="vertical"> <TabWidget android:layout_width="match_parent" android:orientation="vertical" android:layout_height="wrap_content" android:id="@android:id/tabs"></TabWidget> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/tabcontent"> <LinearLayout android:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_1" /> <Button android:id="@+id/bt_cg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="chageTab" /> </LinearLayout> <LinearLayout android:id="@+id/tab2" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/view2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_2" /> </LinearLayout> <LinearLayout android:id="@+id/tab3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_3" /> </LinearLayout> <LinearLayout android:id="@+id/tab4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_4" /> </LinearLayout> </FrameLayout> </LinearLayout> </TabHost> </LinearLayout>
有时候需要tabhost里面的标签按钮置于底部,可以对xml文件进行如下修改:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabHost android:id="@+id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="match_parent" android:orientation="vertical"> <TabWidget android:layout_width="match_parent" android:layout_alignParentBottom="true" android:orientation="vertical" android:layout_height="wrap_content" android:id="@android:id/tabs"></TabWidget> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/tabcontent"> <LinearLayout android:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_1" /> <Button android:id="@+id/bt_cg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="chageTab" /> </LinearLayout> <LinearLayout android:id="@+id/tab2" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/view2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_2" /> </LinearLayout> <LinearLayout android:id="@+id/tab3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_3" /> </LinearLayout> <LinearLayout android:id="@+id/tab4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/view4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/textView_4" /> </LinearLayout> </FrameLayout> </RelativeLayout> </TabHost> </LinearLayout>
效果如图:
发表评论
-
EditText软键盘弹出问题解决
2013-02-26 23:10 1433当带有EditView的activity第一次进入时,第一 ... -
android中获取系统相关属性adb
2012-11-15 14:41 21661.查看系统相关属性可以通过: adb shell ... -
Android使用Intent传递复杂参数及复杂参数列表
2012-11-05 17:29 1598刚开始一直纠结于Intent只能put像int, ... -
解决P6200/P6800扩展卡第三方软件不可写的BUG
2012-11-05 17:01 1002从XDA看来的步骤:1. Using a root-e ... -
android 中跟actionbar相关的属性
2012-10-25 17:07 2449android:uiOptions 这个属性用于设置A ... -
source insight使用快捷键
2012-10-25 10:59 1521F5指定行号,实现行跳转,在遇到编译错误的时候,能特 ... -
android中推出应用比较有效率的方法
2012-10-11 16:57 1137添加一个全局变量作为程序退出的标记(boolean类型) ... -
declare-styleable的使用
2012-10-09 13:59 1140declare-styleable的使用 decl ... -
android程序安全的建议
2012-09-29 14:58 5231如果保证自己的 ... -
Java自带的线程池ThreadPoolExecutor详细介绍说明和实例应用
2012-09-29 14:45 1051从 Java 5 开始,Java 提供了自己的线程池。线 ... -
android应用检测更新代码
2012-09-24 17:40 1765JAVA代码: UpdateManager.java ... -
adb命令详解
2012-09-19 15:04 2803Android adb的常用命令略解 Androi ... -
android中屏蔽其它系统按钮的dialog
2012-09-18 10:13 1624public class MyProgress ... -
如何给Scrollview里内容截屏并生成bitmap,注意:Scrollview里面内容较多有滚动了
2012-09-18 10:07 1614使用for循环递归累加其内部的子控件的高度: p ... -
wakelock的使用
2012-09-17 11:44 10048PowerManager.WakerLock是我分析St ... -
启动另外一个apk
2012-09-14 13:16 871这篇博文主要是获取其他apk程序的启动的主intent, ... -
android中全屏的方法
2012-09-14 13:04 9381.直接代码编写 @Override ... -
android:installLocation简析
2012-09-12 15:25 1085在Froyo(android 2.2,API Le ... -
外部apk启动启动另外一个apk
2012-09-06 17:54 1019public class TestingBroadc ... -
listview如何实现圆角
2012-09-05 17:32 1913首先呢,我们还是看几个示图:(这是360推出的一款天气预 ...
相关推荐
介绍Android开发中TabHost(分页卡)的使用。实现TabHost中各个Activity的切换跳转
Android 嵌套TabHost示例. 两层TabHost嵌套,实现的效果类似网页上的二级菜单栏。
androidTabhost的使用实例代码,仅供参考
android Tabhost使用Demo
自定义Android中TabHost组件显示在屏幕底部,并实现滑动切换页面。在此基础上可以实现类似米聊等软件主界面的Tab效果。
Android实现tabHost控件自定义页签页面源码
Android_TabHost_TabWidget选项卡总结
Android使用tabhost源码
android tabhost activitygroup 源码 分享给有需要的朋友们
TabHost的使用方法,适合初学者,适合课堂讲授实现模拟显示未接来电、已接来电和拨出电话的选项卡。
android TabHost(标签)的使用 简单实例。
最近在使用TabHost的时候遇到了一些奇怪的问题,在这里总结分享备忘一下。
NULL 博文链接:https://technicalsearch.iteye.com/blog/1924614
Android的tabHost案例,适合初学者的Android的tabHost案例,适合初学者,里面有注释,代码清晰明了,导入项目即可使用,亲测可用
Android studio开发,布局TabHost布局 demo,包括修改tab布局: tab栏字体颜色,tab栏大小等布局.
android TabHost使用详解 TabHost从布局到代码的使用步骤
Android Tabhost 实例demo 自定义Tabhost实现实例。
Android_TabHost+ListView组合使用,重写listview,可以全部显示listview
android 为TabHost添加标签的实现源码,新建一个newTabSpec(newTabSpec),设置其标签和图标(setIndicator),设置内容(setContent),设置TabHost的背景颜色,设置TabHost的背景图片资源,mTabHost....