使用TabHost和LocalActivityManager时的Andr​​oid OnResume不叫 [英] Android OnResume not called when using TabHost and LocalActivityManager

查看:155
本文介绍了使用TabHost和LocalActivityManager时的Andr​​oid OnResume不叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成立了一个tabhost有两个活动,因为我无法用我TabActivity用LocalActivityManager,但是当我切换标签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);

我有dispatchResume和dispatchPause放置在适当的地方,但他们只在主卡的活动得到一个onResume或火灾的onPause。我试图通过改变BAB烧制dispatchResume解决我的问题,但似乎不被解雇。

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();

     }

});

有谁知道如何确保onResume被激发的活动,因为他们选择了我可以更新选项卡中的内容?

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?

推荐答案

您有第二个参数真正初始化mlam:
mlam =新LocalActivityManager(这一点,真正的);

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

和那么只有一个活动是在恢复中tabhost的一段时间。

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

这篇关于使用TabHost和LocalActivityManager时的Andr​​oid OnResume不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆