Reputation: 2674
Just starting out on android developing. To start off, I'm building an app which is gonna function like a gallery+image viewer, with the added functionality of quickly and swiftly moving pictures into subfolders, for easy sorting of lots of pictures.
So far I have 2 activites - a full screen image view, and a full screen thumbnail grid (for multiselect purposes).
Now as I'm new at this, I was wondering if this dual-activity was a wise decision. Would it be better to simply switch between content views than to power up an entirely different activity when switching from image view to grid view (and vice versa).
What I'm looking for are of course the obvious pros and cons - performance, ease and usability. But also if there are more fundamental "pattern"/best practice reasons for one or the other.
Thanks
Upvotes: 6
Views: 2334
Reputation: 22822
Activities were made exactly for this purpose. If you prefer, you can have your whole application in a single activity with a custom layout engine (reload components, etc.) and that's what you want to do if you want a "portable" app (e.g. you develop an app with a common UI for various platforms, Andropid, Windows 7, iOS, etc.), but if you want to go Android only, the preferred way is to use the provided APIs, and not to reinvent the wheel. It works fine, and will give users a comforting sense of consistency in their experience (it will look and feel like other Android apps).
The current project I'm working on (a game) already has 10 different activities, and I'm planning more...
Upvotes: 1
Reputation: 3393
I think your dual activity approach is sensible. Generally speaking the Android Activity/View APIs are structured around having a single fixed View per Activity. Although you can manipulate Views within your Activity's layout, I'd suggest this should be restricted to hiding/showing/moving Views rather than replacing the layout wholesale.
What you probably should consider is the newer Fragments API. This can almost be though of as "activities within activities". A Fragment essentially allows you to wrap up an element of a UI (layout and behaviour) in a reusable component. So in your specific example, the two distinct UIs could be Fragments within a single activity.
This has a couple of benefits such as being able to reuse your UIs in other activities and you can do funky transition animations.
Upvotes: 5
Reputation: 8304
dual activity should work, as you won't be bothered by implementing the back button action.
Upvotes: 1