android 仿新浪底部,Android实现新浪微博那种样式的底部标签

Android实现新浪微博那种样式的底部标签,效果真滴灰常不错,不用不知道,一用吓一跳,放心,是惊喜,不是惊吓。

代码示例:

package com.good;

import android.app.TabActivity;

import android.content.Intent;

import android.os.Bundle;

import android.view.Window;

import android.widget.CompoundButton;

import android.widget.RadioButton;

import android.widget.RadioGroup;

import android.widget.RadioGroup.OnCheckedChangeListener;

import android.widget.TabHost;

public class MyTab extends TabActivity implements OnCheckedChangeListener, android.widget.CompoundButton.OnCheckedChangeListener {

private TabHost mHost;

private Intent mMBlogIntent;

private Intent mMoreIntent;

private Intent mInfoIntent;

private Intent mSearchIntent;

private Intent mUserInfoIntent;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.maintabs);

// ~~~~~~~~~~~~ 初始化

this.mMBlogIntent = new Intent(this, HomeListActivity.class);

this.mSearchIntent = new Intent(this, SearchSquareActivity.class);

this.mInfoIntent = new Intent(this, MessageGroup.class);

this.mUserInfoIntent = new Intent(this, MyInfoActivity.class);

this.mMoreIntent = new Intent(this, MoreItemsActivity.class);

initRadios();

setupIntent();

}

/**

* 初始化底部按钮

*/

private void initRadios() {

((RadioButton) findViewById(R.id.radio_button0)).setOnCheckedChangeListener(this);

((RadioButton) findViewById(R.id.radio_button1)).setOnCheckedChangeListener(this);

((RadioButton) findViewById(R.id.radio_button2)).setOnCheckedChangeListener(this);

((RadioButton) findViewById(R.id.radio_button3)).setOnCheckedChangeListener(this);

((RadioButton) findViewById(R.id.radio_button4)).setOnCheckedChangeListener(this);

}

/**

* 切换模块

*/

public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

if (isChecked) {

switch (buttonView.getId()) {

case R.id.radio_button0:

this.mHost.setCurrentTabByTag("mblog_tab");

break;

case R.id.radio_button1:

this.mHost.setCurrentTabByTag("message_tab");

break;

case R.id.radio_button2:

this.mHost.setCurrentTabByTag("userinfo_tab");

break;

case R.id.radio_button3:

this.mHost.setCurrentTabByTag("search_tab");

break;

case R.id.radio_button4:

this.mHost.setCurrentTabByTag("more_tab");

break;

}

}

}

private void setupIntent() {

this.mHost = getTabHost();

TabHost localTabHost = this.mHost;

localTabHost.addTab(buildTabSpec("mblog_tab", R.string.mainpage,

R.drawable.x_icon_shouye, this.mMBlogIntent));

localTabHost.addTab(buildTabSpec("message_tab", R.string.xinxi,

R.drawable.x_icon_xinxi, this.mInfoIntent));

localTabHost.addTab(buildTabSpec("userinfo_tab", R.string.myInfo,

R.drawable.x_icon_wodeziliao, this.mUserInfoIntent));

localTabHost.addTab(buildTabSpec("search_tab", R.string.search,

R.drawable.x_icon_sousuo, this.mSearchIntent));

localTabHost.addTab(buildTabSpec("more_tab", R.string.more,

R.drawable.x_icon_more, this.mMoreIntent));

}

private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon, final Intent content) {

return this.mHost

.newTabSpec(tag)

.setIndicator(getString(resLabel),

getResources().getDrawable(resIcon))

.setContent(content);

}

@Override

public void onCheckedChanged(RadioGroup group, int checkedId) {

// TODO Auto-generated method stub

}

}

下载在Linux公社的1号FTP服务器里,下载地址:

用户名:www.linuxidc.com

密码:www.muu.cc

在 2011年LinuxIDC.com\10月\Android实现新浪微博那种样式的底部标签

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值