タブホストとタブスペックを含むクラス以外のクラスから、タブホストで setCurrentTab を呼び出すことができるかどうか尋ねています。
入れますか
tabHost.setCurrentTab(1);
これとは別のクラスで:
public class Main extends TabActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v("", "Welcome in Main");
setContentView(R.layout.tab);
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); // Le TabHost a des Tabs
TabSpec firstTabSpec = tabHost.newTabSpec("tid1"); // TabSpec: new tab - TabSpec : setContent to the tab
firstTabSpec.setIndicator("Informations", getResources().getDrawable(R.drawable.database)).setContent(new Intent(this,FirstTab.class));
tabHost.addTab(firstTabSpec);
TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
secondTabSpec.setIndicator("Graphiques", getResources().getDrawable(R.drawable.chart)).setContent(new Intent(this,SecondTab.class));
tabHost.addTab(secondTabSpec);
TabSpec thirdTabSpec = tabHost.newTabSpec("tid1"); // tid1 is firstTabSpec Id (used to access outside)
thirdTabSpec.setIndicator("Réglages", getResources().getDrawable(R.drawable.settings)).setContent(new Intent(this,ThirdTab.class));
tabHost.addTab(thirdTabSpec);
}
}
静的変数にすることはできますか? どうすればこれを達成できますか?
ご清聴ありがとうございました!