参考

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. java.lang.NoClassDefFoundError的原因及解决

    [O] 安卓应用在低版本(V2.3.6)系统上运行时报错: java.lang.NoClassDefFoundError 完整错误信息如下: 05-29 13:56:13.687: E/Android ...

  2. Jquery CheckBox复选框 全选/取消全选 最佳实现方式 参考案例

    <input id="chkAll" type="checkbox" />全选/取消全选</div> <asp:Repeater ...

  3. ACTIVEX 重新安装与卸载

    1.卸载工具 SREngLdr.EXE,打开后执行 系统修复->浏览器加载项,找到对应的ACTIVEX,点击删除.OK 2.开发人员如遇到ACTIVEX版本更新.可在OBJECT 里加入更高版本 ...

  4. React-Native牛刀小试仿京东砍啊砍砍到你手软

    React-Native牛刀小试仿京东砍啊砍砍到你手软 React-Native基础教程 *React-Native基础篇作者git *React-Native官方文档 *Demo 几个月前faceb ...

  5. Objective-C 获取当前执行函数的名称

    当打印日志时为了方便跟踪,需要抛出当前执行函数的名称,一样可以使用c++的宏__FUNCTION__实现. @implementation CTPerson -(void)show { NSLog(@ ...

  6. 【C++11】新特性——Lambda函数

    本篇文章由:http://www.sollyu.com/c11-new-lambda-function/ 文章列表 本文章为系列文章 [C++11]新特性--auto的使用 http://www.so ...

  7. SQL Join 的三种类型

    1.Hash Match Join Hash运算(即散列算法) 和Hash表. Hash运算是一种编程技术,用来把数据转换为符号形式,使数据可以更容易更快速地被检索.例如,表中的一行数据,可以通过程序 ...

  8. Git---Git及GitHub使用笔记

    一.远程项目获取(克隆) syntax: $ git clone <版本库的网址> $ git clone <版本库的网址> <本地目录名> example: $ ...

  9. shell中的条件判断

    read命令 命令的语法: read [参数] 变量名 常用的参数如下: -t timeout 设定超时时间. -p prompt 设定提示信息,该提示信息将会显在光标前. 条件测试: 条件测试可以判 ...

  10. event的属性

    t获取鼠标相对于浏览器左上角的坐标 <div id="dv" style=" width:300px; height:200px; background-color ...