public class Tagpage extends TabActivity {
private RadioGroup mGroup;
private TabHost mTabHost;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.mGroup = ((RadioGroup) findViewById(R.id.main_radio));// R.id.group
this.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");
}
}
});
}
}
TabHos基本用法
最新推荐文章于 2015-07-27 18:19:21 发布