android使用tabhost实现导航
参考
http://blog.csdn.net/xixinyan/article/details/6771341
http://blog.sina.com.cn/s/blog_6b04c8eb0101a2ej.html
xml
<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">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"> <!-- 将导航栏tab放置底部 -->
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/chocolate"
android:textColor = "@color/darkgray"
android:layout_marginBottom="-3dip" /> <!-- "去掉最下方的亮色条" -->
</LinearLayout>
</TabHost>
java
public class MainTab extends TabActivity {
ActionBar actionBar;
boolean isExit;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainintent);
actionBar = getActionBar();
actionBar.hide();
// 获取该Activity里面的TabHost组件
TabHost tabHost = getTabHost();
// 使用Intent添加第一个Tab页面
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("AA")
// ,getResources().getDrawable(R.drawable.ic_launcher))
.setContent(new Intent(this, AA.class)));
// 使用Intent添加第二个Tab页面
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("BB")
.setContent(new Intent(this, BB.class)));
}
// 设置TabHost的背景颜色
tabHost.setBackgroundColor(Color.argb(150, 22, 70, 150));
// 设置TabHost的背景图片资源
// mTabHost.setBackgroundResource(R.drawable.bg0);
// 设置当前显示哪一个标签
tabHost.setCurrentTab(0);
android使用tabhost实现导航的更多相关文章
- Android ViewPager+TabHost实现首页导航
今天发的是TabHost结合ViewPager实现首页底部导航的效果,虽然说网上有很多这样的Demo,不过呢,我还是要把自己练习写的发出来,没错!就是这么任性: 先上效果图,如下: 代码里面有注释,就 ...
- Android隐藏状态栏、导航栏
Android隐藏状态栏.导航栏 private void hideStatusNavigationBar(){ if(Build.VERSION.SDK_INT<16){ this.getWi ...
- Android 抽屉效果的导航菜单实现
Android 抽屉效果的导航菜单实现 抽屉效果的导航菜单 看了很多应用,觉得这种侧滑的抽屉效果的菜单很好. 不用切换到另一个页面,也不用去按菜单的硬件按钮,直接在界面上一个按钮点击,菜单就滑出来,而 ...
- Android底部TabHost API
今天在项目中遇到了底部TabHost,顺便就写了一个底部TabHost的api继承即可使用非常简单,以下为源代码: 首先是自定义的TabHostActivity,如果要使用该TabHost继承该类即可 ...
- 12.Android之Tabhost组件学习
TabHost是整个Tab的容器,TabHost的实现有两种方式: 第一种继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost.各个Tab中的内容在布 ...
- android之TabHost(下)
首先建立res/layout/tab.xml文件 编写代码如下: <?xml version="1.0" encoding="utf-8"?> &l ...
- android之TabHost(上)
首先建立文件res/layout/tab.xml 代码如下: <?xml version="1.0" encoding="utf-8"?> < ...
- Android:TabHost实现Tab切换
TabHost是整个Tab的容器,包含TabWidget和FrameLayout两个部分,TabWidget是每个Tab的表情,FrameLayout是Tab内容. 实现方式有两种: 1.继承TabA ...
- Android选项卡TabHost方式实现
1.布局XML: <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android= ...
随机推荐
- c语言学习之基础知识点介绍(十七):写入读取结构体、数组、结构体数组
一.结构体的写入和读取 //写入结构体 FILE *fp = fopen("/Users/ios/Desktop/1.data", "w"); if (fp) ...
- 学习笔记_过滤器应用(粗粒度权限控制(拦截是否登录、拦截用户名admin权限))
RBAC ->基于角色的权限控制 l tb_user l tb_role l tb_userrole l tb_menu(增.删.改.查) l tb_rolemenu 1 说明 我们给 ...
- IOS动态修改按钮响应时间
在项目开发中我们可能会遇到这样子的情况,比如在我们登陆的时候需要把数据发送给服务器进行比对,通常我们的做法是当用户点击按钮后,使用一个加载效果的view遮挡住当前界面,直到服务器返回数据或者超时.如果 ...
- 关于Debug下的Log打印问题
在项目中为了调试经常会用到Log打印,比如打印当前方法__func__, 对象,地址等等,所以项目最后每次运行调试控制台满满的都是打印日志,到release发布的时候,显然不太合适,这里其实可以用一个 ...
- Dynamic Programming: From novice to advanced
作者:Dumitru 出处:http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=dynProg An impo ...
- 九度OJ 1435 迷瘴
题目地址:http://ac.jobdu.com/problem.php?pid=1435 题目描述: 通过悬崖的yifenfei,又面临着幽谷的考验—— 幽谷周围瘴气弥漫,静的可怕,隐约可见地上堆满 ...
- 【转】PHP网站常见安全漏洞,及相应防范措施总结
---恢复内容开始--- 目前,基于PHP的网站开发已经成为目前网站开发的主流,本文笔者重点从PHP网站攻击与安全防范方面进行探究,旨在减少网站漏洞,希望对大家有所帮助! 一.常见PHP网站安全漏洞 ...
- absolute之整体布局实现
要实现如图的布局,我最先想到是将header与footer绝对定位,但是发现在移动端会出现bug,经查资料发现用absolute实现整体布局非常好,还挺简单的. .header, .footer, . ...
- JQuery上传插件Uploadify
一:官网 http://www.uploadify.com/ 二:引用 <link href="plug-in/uploadify3.2.1/uploadify.css" r ...
- BOM 子对象,history,location,screen
history:包括浏览器访问过的 url 属性:返回浏览器访问过的历史记录数 方法:back(); forward(); go(number) location:包含当前 url 的相关信息 属性: ...