- 浏览: 3506401 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (1491)
- Hibernate (28)
- spring (37)
- struts2 (19)
- jsp (12)
- servlet (2)
- mysql (24)
- tomcat (3)
- weblogic (1)
- ajax (36)
- jquery (47)
- html (43)
- JS (32)
- ibatis (0)
- DWR (3)
- EXTJS (43)
- Linux (15)
- Maven (3)
- python (8)
- 其他 (8)
- JAVASE (6)
- java javase string (0)
- JAVA 语法 (3)
- juddiv3 (15)
- Mule (1)
- jquery easyui (2)
- mule esb (1)
- java (644)
- log4j (4)
- weka (12)
- android (257)
- web services (4)
- PHP (1)
- 算法 (18)
- 数据结构 算法 (7)
- 数据挖掘 (4)
- 期刊 (6)
- 面试 (5)
- C++ (1)
- 论文 (10)
- 工作 (1)
- 数据结构 (6)
- JAVA配置 (1)
- JAVA垃圾回收 (2)
- SVM (13)
- web st (1)
- jvm (7)
- weka libsvm (1)
- weka屈伟 (1)
- job (2)
- 排序 算法 面试 (3)
- spss (2)
- 搜索引擎 (6)
- java 爬虫 (6)
- 分布式 (1)
- data ming (1)
- eclipse (6)
- 正则表达式 (1)
- 分词器 (2)
- 张孝祥 (1)
- solr (3)
- nutch (1)
- 爬虫 (4)
- lucene (3)
- 狗日的腾讯 (1)
- 我的收藏网址 (13)
- 网络 (1)
- java 数据结构 (22)
- ACM (7)
- jboss (0)
- 大纸 (10)
- maven2 (0)
- elipse (0)
- SVN使用 (2)
- office (1)
- .net (14)
- extjs4 (2)
- zhaopin (0)
- C (2)
- spring mvc (5)
- JPA (9)
- iphone (3)
- css (3)
- 前端框架 (2)
- jui (1)
- dwz (1)
- joomla (1)
- im (1)
- web (2)
- 1 (0)
- 移动UI (1)
- java (1)
- jsoup (1)
- 管理模板 (2)
- javajava (1)
- kali (7)
- 单片机 (1)
- 嵌入式 (1)
- mybatis (2)
- layui (7)
- asp (12)
- asp.net (1)
- sql (1)
- c# (4)
- andorid (1)
- 地价 (1)
- yihuo (1)
- oracle (1)
最新评论
-
endual:
https://blog.csdn.net/chenxbxh2 ...
IE6 bug -
ice86rain:
你好,ES跑起来了吗?我的在tomcat启动时卡在这里Hibe ...
ES架构技术介绍 -
TopLongMan:
...
java public ,protect,friendly,private的方法权限(转) -
贝塔ZQ:
java实现操作word中的表格内容,用插件实现的话,可以试试 ...
java 读取 doc poi读取word中的表格(转) -
ysj570440569:
Maven多模块spring + springMVC + JP ...
Spring+SpringMVC+JPA
2011.09.14(3)——— android 自定义tabhost的tabs
参考:http://www.cnblogs.com/over140/archive/2011/03/02/1968042.html
我们直接用系统的tabhost时 如下图
可以看见 两个tab中间有空隙 也许我们不需要这些空隙或者系统的样式 但是没有相关的xml属性来修改 所以我们可以自定义tabs
效果如下图 可以看见 没有了中间的空隙
我们用单选按钮来实现tabs
1、看布局文件
关键 在于 TabWidget里面
2、代码
主要是三个方法:
初始化Tabhost
初始化RadioButton
设置切换事件
1. 由于TabWidget被隐藏,所以相关的事件也会无效,这里取巧用RadioGroup与RadioButton的特性来处理切换,然后监听事件调用setCurrentTabByTag来切换Activity。
2. 注意即使TabWidget被隐藏,也要为其设置indicator,否则会保持。
参考:http://www.cnblogs.com/over140/archive/2011/03/02/1968042.html
我们直接用系统的tabhost时 如下图
可以看见 两个tab中间有空隙 也许我们不需要这些空隙或者系统的样式 但是没有相关的xml属性来修改 所以我们可以自定义tabs
效果如下图 可以看见 没有了中间的空隙
我们用单选按钮来实现tabs
1、看布局文件
- <?xml version="1.0" encoding="utf-8"?>
- <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/tabhost"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background = "#d7d7d7">
- <LinearLayout android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <FrameLayout android:id="@android:id/tabcontent"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight = "1">
- </FrameLayout>
- <TabWidget android:id="@android:id/tabs"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:visibility = "gone"/>
- <RadioGroup android:gravity="right"
- android:layout_gravity="bottom"
- android:orientation="horizontal"
- android:id="@+id/main_radio"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <RadioButton
- android:id="@+id/radio_contact"
- android:layout_marginTop="2.0dip"
- android:background = "@drawable/tabcontact"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:button= "@null"
- />
- <RadioButton android:checked="true"
- android:id="@+id/radio_session"
- android:layout_marginTop="2.0dip"
- android:background = "@drawable/tabsession"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:button= "@null"/>
- <RadioButton
- android:id="@+id/radio_setting"
- android:layout_marginTop="2.0dip"
- android:background = "@drawable/tabsetting"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:button= "@null"
- />
- </RadioGroup>
- </LinearLayout>
- </TabHost>
关键 在于 TabWidget里面
2、代码
主要是三个方法:
初始化Tabhost
- private void initTabHost() {
- mTabHost = getTabHost();
- mTabHost.addTab(mTabHost.newTabSpec("tab session").setIndicator(
- "").setContent(new Intent(this,SessionListActivity.class)));
- mTabHost.addTab(mTabHost.newTabSpec("tab contact").setIndicator(
- "").setContent(new Intent(this,ContactListActivity.class)));
- mTabHost.addTab(mTabHost.newTabSpec("tab setting").setIndicator(
- "").setContent(new Intent(this,UserSettingActivitiy.class)));
- mTabHost.setCurrentTabByTag(_contactListTag);
- mTabHost.setCurrentTabByTag(_settingTag);
- mTabHost.setCurrentTabByTag(_sessionListTag);
- }
初始化RadioButton
- private void initTabWidget() {
- ((RadioButton) findViewById(R.id.radio_session)).setOnCheckedChangeListener(this);
- ((RadioButton) findViewById(R.id.radio_contact)).setOnCheckedChangeListener(this);
- ((RadioButton) findViewById(R.id.radio_setting)).setOnCheckedChangeListener(this);
- }
设置切换事件
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked) {
- switch (buttonView.getId()) {
- case R.id.radio_contact:
- this.mTabHost.setCurrentTabByTag(_contactListTag);
- break;
- case R.id.radio_session:
- this.mTabHost.setCurrentTabByTag(_sessionListTag);
- break;
- case R.id.radio_setting:
- this.mTabHost.setCurrentTabByTag(_settingTag);
- break;
- }
- }
- }
1. 由于TabWidget被隐藏,所以相关的事件也会无效,这里取巧用RadioGroup与RadioButton的特性来处理切换,然后监听事件调用setCurrentTabByTag来切换Activity。
2. 注意即使TabWidget被隐藏,也要为其设置indicator,否则会保持。
发表评论
-
android离线
2019-11-04 21:25 259https://www.jianshu.com/p/fdfc4 ... -
android 异步更新
2015-07-11 22:42 1465http://www.apkbus.com/forum.php ... -
仿微米
2015-06-26 10:22 0http://www.javaapk.com/source/4 ... -
仿微信
2015-06-26 10:21 1872http://www.javaapk.com/source/1 ... -
网易客户端
2015-06-26 10:20 1562http://www.javaapk.com/source/4 ... -
仿朋友圈
2015-06-26 10:18 1664http://www.javaapk.com/source/8 ... -
仿朋友圈
2015-06-26 10:13 1778http://www.eoeandroid.com/threa ... -
全国ABC查询
2015-06-26 10:07 1272IM 功能 环信云 信息统计 Umeng 分享Umeng 更新 ... -
android 判断网络
2015-06-25 16:00 1220http://www.cnblogs.com/renqingp ... -
android 多彩表格
2015-05-31 16:06 1432http://blog.csdn.net/conowen/ar ... -
android socket
2015-05-31 16:01 1593http://blog.csdn.net/conowen/ar ... -
微信播放语音3
2015-02-25 12:00 1392http://download.csdn.net/detail ... -
微信语音播放2
2015-02-25 11:57 1296http://download.csdn.net/detail ... -
微信语音播放
2015-02-25 11:56 1643http://www.apkbus.com/android-1 ... -
超强的资料整合
2015-01-05 11:04 1196http://zz563143188.iteye.com/bl ... -
最强开发资源平台大合集
2015-01-04 14:50 1851程序员代码应用开发平 ... -
Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
2014-09-04 15:45 1334http://blog.csdn.net/vipzjyno1/ ... -
android应用推广
2014-09-03 23:25 1279应用推广不必愁,有米 ... -
android 图片异步加载
2014-09-03 16:47 1096http://www.csdn.net/article/201 ... -
android hander的使用
2014-09-02 23:46 1322http://www.cnblogs.com/xiaoran1 ...
相关推荐
自定义tabhost,实现新浪微博效果
使用了自定义button,自定义tabhost使用了不同默认的上标签切换页面
NULL 博文链接:https://jykenan.iteye.com/blog/855843
android 自定义实现TAB, 简化开发代码,提供效率
android的自定义TabHost,界面还是不错的哦,漂亮。
自定义TabHost,实现标签在页面底部,并且标签选项卡可以显示图标和文件
自定义tabhost实现activity 的跳转 界面比较简单 但功能都实现了
字定义TabHost,实现更换tabhost的背景颜色
Android Tabhost 实例demo 自定义Tabhost实现实例。
很多情况下,我们需要用到标签,类似于微末下面的标签效果,直接使用系统默认的往往不能满足项目的需求,就需要我们自定义一个TabHost。下面我把在项目的实现的效果分享给大家,希望能帮助需要的朋友!
Android 嵌套TabHost示例. 两层TabHost嵌套,实现的效果类似网页上的二级菜单栏。
tabhost,tab控制按钮图片文字切换,自己可以任意定义变更。
自定义TabHost各种经典实现,突破了传统的固定模式,内有word文档代码详解!
自定义Android中TabHost组件显示在屏幕底部,并实现滑动切换页面。在此基础上可以实现类似米聊等软件主界面的Tab效果。
自定义TabHost 图片在左文字在右 可以结合修改为新的布局
自定义TabHost实现背景图片随选项卡切换滑动效果
Android裡提供了TabHost,讓開發人員可以製做Tab版型;但是預設的樣式一點都不討喜。如果要自己重新設計版面其實也不太難,可直接运行,自定义的tabhost样式
自定义TabHost,一个简单的的例子,通过嵌套来改变TabHost的位置
自定义Tabhost实现滑动切换,利用GridView,listView实现自定义布局
Android系统自带的TabHost控件很难看,这是一个自定义TabHost例子,显示在底部,类似于微博下面的Tab选项卡