安卓:什么是更好 - 多重活动或手动切换视图? [英] Android: What is better - multiple activities or switching views manually?

查看:129
本文介绍了安卓:什么是更好 - 多重活动或手动切换视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一些应用程序为Android,而这个问题始终停留:

I have developed some apps for Android, and this questions stays always:

我应该如何构建我的用户界面?我应该推出活动活动后留下的电话打了后退按钮,或者我应该选择更优化,但更复杂的实现,具有开关方式手动意见,然后手工做的后退按钮的功能?

How should I structure my UI? Should I launch activity after activity and leave the phone to make the "back" button, or should I choose more optimized, but more complex to implement, way with switching manually Views and then manually doing the "Back" button functionality?

你觉得(或不知道)是更好的做法?

What do you think (or know) is the better practice?

推荐答案

我要说的是,多个活动几乎总是更有意义。我只是不认为Android是专为不断切换自己的看法 - 你错过了这么多。你必须实现回你自己,你没有得到任何内部活动的过渡,你必须执行大量的内部逻辑来恢复正确的状态的应用程序。如果你不分区你的应用程序变成活动,它使困难得多后来就改变你的应用程序的流程。这也导致在一个大型的活动,可以是很多更难处理比很多小件code。

I would say that multiple Activities almost always makes more sense. I just don't think Android is designed for constantly switching its own views - you miss out on so much. You have to implement Back yourself, you don't get any inter-Activity transitions, you have to implement a lot of internal logic to resume an application in the correct state. If you don't partition your app into Activities, it makes it a lot more difficult later on to change the flow of your application. It also results in one mega-Activity that can be a lot harder to handle than a lot of smaller pieces of code.

我有麻烦想象的速度是一个真正的问题;如果再有什么问题你初始化每个活动的方式。例如,我曾经尝试通过活动之​​间的序列化对象,并且被证明是极其缓慢的;当我切换到传递对象的更快的方法,对开展活动的速度大幅度提升了。

I have trouble imagining that speed is really an issue; if it is then there's something wrong with the way you're initializing each Activity. For example, I used try to pass Serializable objects between Activities, and that proved to be incredibly slow; when I switched to a faster method of passing objects, the speed of launching Activities increased immensely.

另外,我认为它告诉了 Android的指南活动和任务设计别牛逼一提的开关在所有的意见;它围绕着一个活动的 - 视图的设计。

Also, I think it's telling that the Android guidelines for Activity and Task Design don't mention switching Views at all; it's centered around an Activity-as-View design.

这篇关于安卓:什么是更好 - 多重活动或手动切换视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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