Android OnResume not called when using TabHost and LocalActivityManager

三世轮回 提交于 2019-12-07 10:29:29

问题


I set up a tabhost with two activities and since I could not use TabActivity I used LocalActivityManager, but when I switch tabs onResume is not called for the Activities within the tabs. Here is my set up:

mlam = new LocalActivityManager(this, false);
mlam.dispatchCreate(savedInstanceState);
tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup(mlam);

I have the dispatchResume and dispatchPause placed in the proper places, but they only fire when the main tab activity gets an onResume or onPause. I tried to solve my issue by firing the dispatchResume on bab change but that seems to not be firing.

tabHost.setOnTabChangedListener(new OnTabChangeListener(){

    public void onTabChanged(String tabId) {

    mlam.dispatchResume();

     }

});

Does anyone know how to make sure the onResume is fired for the activities so I can update the content within the tabs as they are selected?


回答1:


You have to initialize mlam with the second parameter true: mlam = new LocalActivityManager(this, true);

And then only one activity is resume at the some time in the tabhost.



来源:https://stackoverflow.com/questions/8660540/android-onresume-not-called-when-using-tabhost-and-localactivitymanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!