0
我有如下所示標籤主機,在android中切換選項卡?
private TabHost myTabHost;
......
setContentView(R.layout.vidtab);
Intent intent=getIntent();
intent = new Intent().setClass(this, RecordActivityGroup.class);
myTabHost = (TabHost)this.findViewById(android.R.id.tabhost);
myTabHost.setup();
TabSpec rectab = myTabHost.newTabSpec("Record");
rectab.setIndicator("Record",getResources().getDrawable(R.drawable.irecord));
rectab.setContent(intent);
myTabHost.addTab(rectab);
intent = new Intent().setClass(this, sharingProject.class);
TabSpec setting = myTabHost.newTabSpec("Hint");
setting.setIndicator("Hint",getResources().getDrawable(R.drawable.isettings));
setting.setContent(intent);
myTabHost.addTab(setting);
該記錄活動組中
我有以下代碼,
RecordActivityGroup延伸TabGroupActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startChildActivity("RecordingActivity", new Intent(this,Record.class));
}
和Record.class是一種活動其中包含一個按鈕,我需要切換到第二個選項卡,同時單擊Record類中的按鈕,如何做到這一點?任何人都知道請幫助我。
申報方法switchToTab( ),無論是在tabhost或recordActivitygroup – Karthi 2011-06-02 10:53:09
在你有'私人TabHost myTabHost;' – 2011-06-02 10:53:59
我創建了你在Tabhost類中所說的方法,然後我調用該方法,它拋出類拋出異常。 – Karthi 2011-06-02 11:48:38