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
Android App Development for BeginnersAn activity represents a single screen with a user interface just like window or frame of Java. Android activity is the subclass of ContextThemeWrapper class.
There are only two hard things in Computer Science: cache invalidation and naming things.
Typically, one activity in an app is specified as the main activity, which is the first screen to appear when the user launches the app. Each activity can then start another activity in order to perform different actions.
To speed up your view, eliminate unnecessary code from routines that are called frequently. Start by working on onDraw() , which will give you the biggest payback. In particular you should eliminate allocations in onDraw() , because allocations may lead to a garbage collection that would cause a stutter.
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.
dual activity should work, as you won't be bothered by implementing the back button action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With