使用 TabHost 和 LocalActivityManager 时未调用 Android OnResume

发布于 2024-12-23 08:29:09 字数 663 浏览 2 评论 0原文

我设置了一个包含两个活动的 tabhost,由于我无法使用 TabActivity,所以我使用了 LocalActivityManager,但是当我切换选项卡时,不会为选项卡内的活动调用 onResume。这是我的设置:

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

我将dispatchResume和dispatchPause放置在适当的位置,但它们仅在主选项卡活动获得onResume或onPause时触发。我试图通过在 bab 更改时触发dispatchResume 来解决我的问题,但这似乎没有触发。

tabHost.setOnTabChangedListener(new OnTabChangeListener(){

    public void onTabChanged(String tabId) {

    mlam.dispatchResume();

     }

});

有谁知道如何确保为活动触发 onResume ,以便我可以在选择选项卡时更新选项卡中的内容?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守不住的情 2024-12-30 08:29:09

您必须使用第二个参数 true 来初始化 mlam:
mlam = new LocalActivityManager(this, true);

然后 tabhost 中某个时间只恢复一项活动。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文