参考

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实现导航的更多相关文章

  1. Android ViewPager+TabHost实现首页导航

    今天发的是TabHost结合ViewPager实现首页底部导航的效果,虽然说网上有很多这样的Demo,不过呢,我还是要把自己练习写的发出来,没错!就是这么任性: 先上效果图,如下: 代码里面有注释,就 ...

  2. Android隐藏状态栏、导航栏

    Android隐藏状态栏.导航栏 private void hideStatusNavigationBar(){ if(Build.VERSION.SDK_INT<16){ this.getWi ...

  3. Android 抽屉效果的导航菜单实现

    Android 抽屉效果的导航菜单实现 抽屉效果的导航菜单 看了很多应用,觉得这种侧滑的抽屉效果的菜单很好. 不用切换到另一个页面,也不用去按菜单的硬件按钮,直接在界面上一个按钮点击,菜单就滑出来,而 ...

  4. Android底部TabHost API

    今天在项目中遇到了底部TabHost,顺便就写了一个底部TabHost的api继承即可使用非常简单,以下为源代码: 首先是自定义的TabHostActivity,如果要使用该TabHost继承该类即可 ...

  5. 12.Android之Tabhost组件学习

    TabHost是整个Tab的容器,TabHost的实现有两种方式: 第一种继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost.各个Tab中的内容在布 ...

  6. android之TabHost(下)

    首先建立res/layout/tab.xml文件 编写代码如下: <?xml version="1.0" encoding="utf-8"?> &l ...

  7. android之TabHost(上)

    首先建立文件res/layout/tab.xml 代码如下: <?xml version="1.0" encoding="utf-8"?> < ...

  8. Android:TabHost实现Tab切换

    TabHost是整个Tab的容器,包含TabWidget和FrameLayout两个部分,TabWidget是每个Tab的表情,FrameLayout是Tab内容. 实现方式有两种: 1.继承TabA ...

  9. Android选项卡TabHost方式实现

    1.布局XML: <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android= ...

随机推荐

  1. mysql - 启动错误InnoDB: mmap(137363456 bytes) failed; errno 12

    [zsm]下午mysql出现了问题,很纠结,最后找到了原因,原因是内存不够用: 查看内存显示   [root@AY1305070924544 /]# free -m              tota ...

  2. 网易游戏QA工程师笔试回忆-2012.9【个人题解】

    ========================转帖======================== 网易游戏QA工程师笔试回忆-2012.9 刚刚从武大回来,趁热回忆下题目,给以后的XDJMs参考. ...

  3. php注册登录时生成的验证码

    http://blog.sina.com.cn/s/blog_8173443e01012l82.html 记得我学php时第一件事就是研究登陆注册.当然,登陆少不了验证码.两年过去了,昨天突然想用个验 ...

  4. javascript 之封装技巧

    技术--- 闭包 javascript中的对象属性都是公开的,外界都可访问到,例: function cat(){ this.name = '猫'; this.climb = function(){ ...

  5. 获取键盘输入或者USB扫描枪数据

    /// <summary> /// 获取键盘输入或者USB扫描枪数据 可以是没有焦点 应为使用的是全局钩子 /// USB扫描枪 是模拟键盘按下 /// 这里主要处理扫描枪的值,手动输入的 ...

  6. 九度OJ 1113 二叉树

    题目地址:http://ac.jobdu.com/problem.php?pid=1113 题目描述: 如上所示,由正整数1,2,3……组成了一颗特殊二叉树.我们已知这个二叉树的最后一个结点是n.现在 ...

  7. spark - 从HDFS加载文件并分析

    scala> val file=sc.textFile("/workspace/bpUserinfo_logs/bpUserinfo_20160212.log") scala ...

  8. Mantle 简单教程

    Mantle可以很方便的去书写一个模型层的代码. 使用它可以很方便的去反序列化JSON或者序列化为JSON(需要在MTLModel子类中实现<MTLJSONSerializing>协议) ...

  9. rpm命令详解

    http://www.rpm.org/max-rpm/s1-rpm-install-additional-options.html#S2-RPM-INSTALL-REPLACEFILES-OPTION ...

  10. JavaScript入门介绍(二)

    JavaScript入门介绍 [函数] 函数function 是Javascript的基础模块单元,用于代码的复用.信息影藏和组合调用. function a(){} 函数对象Function Lit ...