选项卡(TabHost)的功能和用法 选项卡置于底部

实现的Activity代码如下:

package com.example.testandroid;

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

public class TabHostBottom extends TabActivity {
private TabHost tabhost;
private Intent news,dingyue,picture,video;
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabhostbottom);
        tabhost=getTabHost();
        news=new Intent(TabHostBottom.this,News.class);
        tabhost.addTab(tabhost.newTabSpec("first")
        		.setIndicator("新闻",getResources().getDrawable(android.R.drawable.ic_menu_gallery))
        		.setContent(news));
        dingyue=new Intent(TabHostBottom.this,Dingyue.class);
        tabhost.addTab(tabhost.newTabSpec("second")
        		.setIndicator("订阅",getResources().getDrawable(android.R.drawable.ic_menu_share))
        		.setContent(dingyue));
        picture=new Intent(TabHostBottom.this,Picture.class);
        tabhost.addTab(tabhost.newTabSpec("third")
        		.setIndicator("图片", getResources().getDrawable(android.R.drawable.ic_menu_slideshow))
        		.setContent(picture));
        video=new Intent(TabHostBottom.this,Video.class);
        tabhost.addTab(tabhost.newTabSpec("fourth")
        		.setIndicator("视频", getResources().getDrawable(android.R.drawable.stat_notify_voicemail))
        		.setContent(video));
        tabhost.setCurrentTab(0);
	}
}


 

对应的界面(选项卡置于底部):

<?xml version="1.0" encoding="utf-8"?>
<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" >

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" >
    </FrameLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <!-- tabStripEnabled属性去掉底部下划线与选项卡间的下划线 -->
        <!-- layout_alignParentBottom属性即可将其放在底部菜单栏,注意,必须在RelativeLayout里 -->

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:tabStripEnabled="true"
            android:layout_alignParentBottom="true"
            android:background="#AEC1EA" >
        </TabWidget>
    </RelativeLayout>

</TabHost>


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值