tags:

views:

52

answers:

2

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 / unload each layout)?

+1  A: 

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.

David Hedlund
Thanks for the quick response.Is it possible to have multiple activities in a single app (would these appear as separate applications?)
source.rar
yes, it's definitely possible to have multiple activities in one app! `startActivity()` is the function you want to use
David Hedlund
+1  A: 

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.

Macarse
Yeah. That does seem to be the best way to go.I had tried a ViewFlipper with 2 layouts, but that always crashes when I try multiple change orientation's.Donno why but looks like the ViewFlipper isn't quite "production grade" right now (tried with 2.1 update 1). :)
source.rar