自定义TabHost

时间:2016-12-08 13:35:45
【文件属性】:

文件名称:自定义TabHost

文件大小:513KB

文件格式:ZIP

更新时间:2016-12-08 13:35:45

TabHost

各种自定义TabHost tab = getTabHost(); context = this; tab.addTab(tab.newTabSpec("A").setIndicator("A").setContent(new Intent(context, AActivity.class))); tab.addTab(tab.newTabSpec("B").setIndicator("B").setContent(new Intent(context, BActivity.class))); tab.addTab(tab.newTabSpec("C").setIndicator("C").setContent(new Intent(context, CActivity.class))); tab.addTab(tab.newTabSpec("D").setIndicator("D").setContent(new Intent(context, DActivity.class))); tab.addTab(tab.newTabSpec("E").setIndicator("E").setContent(new Intent(context, EActivity.class))); rg = (RadioGroup) findViewById(R.id.rg); rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { int idx = -1; if (checkedId == R.id.rb01) { idx = 0; } else if (checkedId == R.id.rb02) { idx = 1; } else if (checkedId == R.id.rb03) { idx = 2; } else if (checkedId == R.id.rb04) { idx = 3; } else if (checkedId == R.id.rb05) { idx = 4; } switchActivity(idx); } });


网友评论