我希望将服务类的成员变量提供给扩展TabActivity的类。
public class MainActivity extends TabActivity {
private TabHost tabHost;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
this.tabHost = (TabHost)findViewById(android.R.id.tabhost);
TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
firstTabSpec.setIndicator("출근").setContent(new Intent(this,FirstTab.class));
tabHost.addTab(firstTabSpec);
}
protected void onPause(){
super.onPause();
// HERE I WANT TO receive value from FirstTab Activity
// firstabOption = ??? .CURRENT_OPTION_IDX ??
}
}
并且FirstTab
类是
public class FirstTab extends Activity {
public int CURRENT_OPTION_IDX;
......
....
....
....
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
CURRENT_OPTION_IDX = item.getItemId();
// save option
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first_tab);
}
}
由于缺乏英语,请原谅我的简洁
我有一个TabActivity
类,有3个标签。我做了一些操作来改变选项卡上的TextView文本。
我希望在TabActivity
的{{1}}出现时保存这些值。