Android中的活动过多? [英] Too many Activities in Android?

查看:104
本文介绍了Android中的活动过多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动Android项目时,我有一个误解,即应用程序中显示的每个屏幕都必须是新的活动.现在,我已经完成了该项目,我已经在模拟器以及几个Android手机上对其进行了检查.到目前为止,我还没有遇到任何问题,但是最近我读到某个地方,应用程序中的太多活动是一个非常糟糕的主意.

When i started my Android project i had a misunderstanding that every screen that's shown in the application must be a new activity. Now i am finished with the project , i have checked it on my emulator as well as on a couple of android phones. So far i am not witnessing any problems, but recently i read somewhere that too many activities in the application are a pretty bad idea.

目前我的应用程序大约有15到20个活动.理想情况下,我听说它应该是5到6个活动.我需要重新组织我的代码还是在完成每部分活动之后就完成每个活动?

Currently my application has around 15-20 activities.Ideally i heard it should be around 5-6. Do i need to re-structure my code or just finishing every activity after it has done it's part is enough?

推荐答案

在创建复杂的应用程序时,您肯定需要创建许多活动.因此,这取决于您的应用程序需要多少活动.项目中的任何活动都不会影响性能.

While creating complex applications you definite need to create many activities. So it depends on your application how many activities you need. No of activities in a project do not affect the performance.

效果是由Android堆栈中的活动数量产生的.因此最好将5-6个活动保留在堆栈中(如果不再需要,请完成活动).

The effect is produced by the number of activities in the stack of your android. So it is better to keep 5-6 activities in the stack(Finish activities if they are not needed any more).

因此,可以根据应用程序的需求创建尽可能多的活动,但同时保持较小的活动数保持不变.

So create as many Activities as your application demands but keep smaller no of Activities open at a time.

这篇关于Android中的活动过多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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