新浪微博的tab工具栏

来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-02 04:18 点击:
package com.flysnow.sina.weibo;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class MainTabActivity extends TabActivity implements OnCheckedChangeListener{
 private RadioGroup mainTab;
 private TabHost mTabHost;
 
 private Intent mHomeIntent;
 private Intent mNewsIntent;
 private Intent mInfoIntent;
 private Intent mSearchIntent;
 private Intent mMoreIntent;
 
 private final static String TAB_TAG_HOME="tab_tag_home";
 private final static String TAB_TAG_NEWS="tab_tag_news";
 private final static String TAB_TAG_INFO="tab_tag_info";
 private final static String TAB_TAG_SEARCH="tab_tag_search";
 private final static String TAB_TAG_MORE="tab_tag_more";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);
       
        mainTab=(RadioGroup)findViewById(R.id.main_tab);
        mainTab.setOnCheckedChangeListener(this);
       
        prepareIntent();
        setupIntent();
    }
  
 private void prepareIntent() {
  mHomeIntent=new Intent(this, HomeActivity.class);
  mNewsIntent=new Intent(this, NewsActivity.class);
  mInfoIntent=new Intent(this, MyInfoActivity.class);
  mSearchIntent=new Intent(this,SearchActivity.class);
  mMoreIntent=new Intent(this, MoreActivity.class);
 }
 
 private void setupIntent() {
  this.mTabHost=getTabHost();
  TabHost localTabHost=this.mTabHost;
  localTabHost.addTab(buildTabSpec(TAB_TAG_HOME, R.string.main_home, R.drawable.icon_1_n, mHomeIntent));
  localTabHost.addTab(buildTabSpec(TAB_TAG_NEWS, R.string.main_news, R.drawable.icon_2_n, mNewsIntent));
  localTabHost.addTab(buildTabSpec(TAB_TAG_INFO, R.string.main_my_info, R.drawable.icon_3_n, mInfoIntent));
  localTabHost.addTab(buildTabSpec(TAB_TAG_SEARCH, R.string.menu_search, R.drawable.icon_4_n, mSearchIntent));
  localTabHost.addTab(buildTabSpec(TAB_TAG_MORE, R.string.more, R.drawable.icon_5_n, mMoreIntent));
 }
 
 private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon,final Intent content) {
  return this.mTabHost.newTabSpec(tag).
          setIndicator(getString(resLabel),getResources().getDrawable(resIcon)).
          setContent(content);
 }
 public void onCheckedChanged(RadioGroup group, int checkedId) {
  switch(checkedId){
  case R.id.radio_button0:
   this.mTabHost.setCurrentTabByTag(TAB_TAG_HOME);
   break;
  case R.id.radio_button1:
   this.mTabHost.setCurrentTabByTag(TAB_TAG_NEWS);
   break;
  case R.id.radio_button2:
   this.mTabHost.setCurrentTabByTag(TAB_TAG_INFO);
 &n

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • Android 完全退出程序
      • 原创:Android应用开发-Andorid歌词秀,含源码
      • android 屏幕保护
      • Android手机软件汉化教程---第四课 dex文件汉化
      • 众多Android 开源项目推荐,给力工作给力学习
      • Android Audio代码分析4
      • Android得到已安装的应用程序信息!
      • Android开发者指南(29) —— USB Host and Accessory
      • Android成长的幕后推手:工程师鲁宾
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1