如何将服务类的公共成员变量获取到TabActivity

时间:2011-09-05 16:03:30

标签: android

我希望将服务类的成员变量提供给扩展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}}出现时保存这些值。

0 个答案:

没有答案