实现的效果不解释,主要是记录一下代码
先看一下xml布局:
二、MainTabActivity
1、系统采用.net2.0开发,数据库access2、三层架构,数据层、逻辑层和表示层分离3、系统完全使用div+css布局,可以灵活处理界面4、技术特点: 使用模板页,大大减少代码量 动态生成竖向导航菜单 ul li实现表格 各种自定义用户空间 Reapter等数据控件的灵活运用
package com.gs.app.main;import android.app.TabActivity;import android.content.Intent;
import android.os.Bundle;import android.view.Window;import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;import android.widget.TabHost;
import com.gs.Appblue.R;import com.gs.app.contact.ContactsListActivity;
import com.gs.app.contact.RecentCallsListActivity;
import com.gs.app.setting.Setting;
import com.gs.app.sms.ActSMSList;
public class MainTabActivity extends TabActivity implementsOnCheckedChangeListener
{private TabHost mTabHost;private Intent mContactIntent;private Intent mCallLogIntent;private Intent mSmsIntent;
private Intent mSetIntent;public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.main_tab);
this.mContactIntent = new Intent(this, ContactsListActivity.class);
this.mCallLogIntent = new Intent(this, RecentCallsListActivity.class);
this.mSmsIntent = new Intent(this, ActSMSList.class);
this.mSetIntent = new Intent(this, Setting.class);
((RadioButton) findViewById(R.id.radio_contact)).setOnCheckedChangeListener(this);
((RadioButton) findViewById(R.id.radio_calllist)).setOnCheckedChangeListener(this);
((RadioButton) findViewById(R.id.radio_sms)).setOnCheckedChangeListener(this);
((RadioButton) findViewById(R.id.radio_setting)).setOnCheckedChangeListener(this);
setupIntent();}private void setupIntent() {this.mTabHost = getTabHost();
TabHost localTabHost = this.mTabHost;
localTabHost.addTab(buildTabSpec("A_TAB", R.string.radio_contact,R.drawable.main_tab_contact_normal, this.mContactIntent));localTabHost.addTab(buildTabSpec("B_TAB", R.string.radio_calllist,R.drawable.main_tab_calllist_normal,
this.mCallLogIntent));localTabHost.addTab(buildTabSpec("C_TAB", R.string.radio_sms,R.drawable.main_tab_sms_normal, this.mSmsIntent));localTabHost.addTab(buildTabSpec("D_TAB", R.string.radio_setting,R.drawable.main_tab_setting_normal, this.mSetIntent));
localTabHost.setCurrentTab(0);}@Overridepublic void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {if (isChecked) {switch (buttonView.getId()) {case R.id.radio_contact:this.mTabHost.setCurrentTabByTag("A_TAB");
break;case R.id.radio_calllist:this.mTabHost.setCurrentTabByTag("B_TAB");break;case R.id.radio_sms:this.mTabHost.setCurrentTabByTag("C_TAB");break;case R.id.radio_setting:this.mTabHost.setCurrentTabByTag("D_TAB");break;}}}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);}}









