Android TabHost风格

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent">
    <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="match_parent" android:orientation="vertical">
        <TabWidget android:layout_width="match_parent" android:id="@android:id/tabs" android:layout_height="wrap_content"></TabWidget>
        <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/tabcontent">

            <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab1">
                <ImageView android:id="@+id/imageView2" android:src="@drawable/intnet" android:layout_width="match_parent" android:layout_height="match_parent"></ImageView>
            </LinearLayout>

            <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab2">
                            <ImageView android:id="@+id/imageView4" android:src="@drawable/reresh" android:layout_height="match_parent" android:layout_width="match_parent"></ImageView>
            </LinearLayout>

            <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab3">
                            <ImageView android:id="@+id/imageView5" android:src="@drawable/search" android:layout_height="match_parent" android:layout_width="match_parent"></ImageView>
            </LinearLayout>

             <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab4">
                             <ImageView android:id="@+id/imageView3" android:src="@drawable/picture" android:layout_height="match_parent" android:layout_width="match_parent"></ImageView>
             </LinearLayout>

            <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab5">
                            <ImageView android:id="@+id/imageView1" android:src="@drawable/info" android:layout_height="match_parent" android:layout_width="match_parent"></ImageView>
            </LinearLayout>

        </FrameLayout>
    </LinearLayout>
</TabHost>
</LinearLayout>



Activity

package rw.Tab;

import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;

public class Tabhost02Activity extends TabActivity {
    /** Called when the activity is first created. */
	 private TabHost tabHost;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tabHost=getTabHost();
        tabHost.addTab(tabHost.newTabSpec("network").setIndicator("流量",getResources().getDrawable(R.drawable.intnet)).setContent(R.id.tab1));
        tabHost.addTab(tabHost.newTabSpec("refesh").setIndicator("刷新",getResources().getDrawable(R.drawable.reresh)).setContent(R.id.tab2));
        tabHost.addTab(tabHost.newTabSpec("search").setIndicator("搜索",getResources().getDrawable(R.drawable.search)).setContent(R.id.tab3));
        tabHost.addTab(tabHost.newTabSpec("picture").setIndicator("图片",getResources().getDrawable(R.drawable.picture)).setContent(R.id.tab4));
        tabHost.addTab(tabHost.newTabSpec("info").setIndicator("信息",getResources().getDrawable(R.drawable.info)).setContent(R.id.tab5));
        
    }
}



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值