开发者

Should app's with multiple layouts have multiple activities to handle each?

I'm planning to develop and app that presents the users with several different screens (of different information). Was wondering what would be the best way to implement this?

Is it better to have separate XML layouts and an activity to display and allow the user to interact with each screen of data?

OR would handling all of these in the same activity be more efficient (and dynamically load / unlo开发者_高级运维ad each layout)?


I'd say you want to go with the former, in the most cases, but obviously it all comes down to what it is that should be changing.

If you end up having two activities with layouts that only slightly differ, and you have to pass a lot of data between them, then it probably should have been one activity.

But in the most cases, where you're dealing with presenting quite separate things, I'd definitely create one activity for each presentation, so that you don't have to manually handle things like the click of the back button.


An Android Activity is a single, focused thing that the user can do. The easier way to explain it is: An Activity is a screen in your app.

You want to have two different screens, then you should have two different Activities.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜