切换到其他活动时是否让活动在后台运行? [英] keep activity going in background when switched to another activity?

查看:92
本文介绍了切换到其他活动时是否让活动在后台运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要进行主要活动,而按钮要进行其他活动.当我去其他活动时,我的主要活动停止了.我将如何进行主要活动?

I have my main activity going and a button going to a different activity. When I go to the other activity my main activity stops. How would I keep the main activity going?

谢谢.

推荐答案

是的,您可以保持主活动运行.我的方法是使用"CHEAT".

Yes, you can keep your main Activity running. My way is use a "CHEAT".

例如,您的主要活动是A,在A中,我们有按钮btnA.单击此btnA将打开活动B.

Example your main Activity is A, in A we have button btnA. Click this btnA will open activity B.

您创建的标签栏包含2个包含A和B的标签.初始化标签栏后,调用

You create a tab bar with 2 tab contains A and B. After initialize tab bar, call

tabHost.getTabWidget.setVisibility(View.GONE);

隐藏该标签.因此,您只会看到可见的主活动.

to hide this tab. So you only see main Activity visible.

单击btnA时,只需将tabHost切换为B

When btnA is clicked, only need to switch tabHost to B

tabHost.setCurrentTab(1);//1 is index of Activity B

此问题&答案与您的问题相似.您可以参考它.

This question & answer is similar with your question. You can refer to it.

活动和子活动

这篇关于切换到其他活动时是否让活动在后台运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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