TabHos基本用法

来源:互联网 发布:ps做淘宝宝贝详情 编辑:程序博客网 时间:2024/05/03 18:02
public class Tagpage extends TabActivity {private RadioGroup mGroup;private TabHost mTabHost;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);this.mGroup = ((RadioGroup) findViewById(R.id.main_radio));// R.id.groupthis.mTabHost = this.getTabHost();Intent localIntent1 = new Intent(this, Page1.class);Intent localIntent2 = new Intent(this, Page2.class);Intent localIntent3 = new Intent(this, Page3.class);this.mTabHost.addTab(this.mTabHost.newTabSpec("all").setIndicator("all").setContent(localIntent1));this.mTabHost.addTab(this.mTabHost.newTabSpec("category").setIndicator("category").setContent(localIntent2));this.mTabHost.addTab(this.mTabHost.newTabSpec("hot").setIndicator("hot").setContent(localIntent3));this.mGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {public void onCheckedChanged(RadioGroup paramRadioGroup,int paramInt) {switch (paramInt) {/* * default: return; */case R.id.radio_button1:Tagpage.this.mTabHost.setCurrentTabByTag("all");return;case R.id.radio_button2:Tagpage.this.mTabHost.setCurrentTabByTag("category");return;case R.id.radio_button3:Tagpage.this.mTabHost.setCurrentTabByTag("hot");return;default:System.out.println("hello");}}});}}

原创粉丝点击