zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    UVA 1515 Pool construction 最大流跑最小割
    BZOJ 1060: [ZJOI2007]时态同步 树形DP
    Codeforces Round #282 (Div. 1)B. Obsessive String KMP+DP
    BZOJ 4027: [HEOI2015]兔子与樱花 贪心
    BZOJ 2435: [Noi2011]道路修建 dfs搜图
    HDU 5297 Y sequence 容斥/迭代
    HDU 5296 Annoying problem dfs序 lca set
    HDU 5289 Assignment RMQ
    343D/Codeforces Round #200 (Div. 1) D. Water Tree dfs序+数据结构
    php mysqli扩展库之预处理操作
  • 原文地址:https://www.cnblogs.com/sudawei/p/3435001.html
Copyright © 2011-2022 走看看