Android 在同一屏幕上显示多个活动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2513518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:07:58  来源:igfitidea点击:

Display multiple activities on same screen

androidandroid-activity

提问by Puneet kaur

Is it possible to show two activities on the same screen at the same time? I need each activity to show data that changes with time.

是否可以在同一屏幕上同时显示两个活动?我需要每个活动来显示随时间变化的数据。

回答by grine4ka

Or maybe you can use AndroidFragments

或者你可以使用AndroidFragments

回答by nine stones

It's late after the question. But you should look at ActivityGroup

问完就晚了。但你应该看看ActivityGroup

Inherits from Activity, so you should be able to run this as the parent.

继承自 Activity,因此您应该能够以父级身份运行它。

回答by Felix

Yes, it is definitely possible. Even when you display a menu or a dialog, that menu/dialog is a separate activity running on top of yours. However, you should avoid doing that as much as possible. It is only useful to display two activities at the same time if one of the activities does not belong to your application (which is the case with menus/dialogs). If both activities come from your own application, you should find a way to merge them into one. This way you use up less memory and less CPU (as there's no overhead of starting a new process).

是的,这绝对是可能的。即使您显示菜单或对话框,该菜单/对话框也是运行在您之上的单独活动。但是,您应该尽可能避免这样做。只有当其中一个活动不属于您的应用程序时(菜单/对话框就是这种情况),同时显示两个活动才有用。如果这两个活动都来自您自己的应用程序,您应该找到一种方法将它们合并为一个。这样你使用更少的内存和更少的 CPU(因为没有启动新进程的开销)。