In my travels through the world of Android I faced a lot of challenges. Brave as I am, *cough* I conquered each one of them. A few of the challenges include saving activity state, asynchronous tasks, pagination, error handling, context/option menu's and even drawing custom application/tab icons in Photoshop! Some challenges I already shared with you guys, but there is one challenge in particular I would like to elaborate on this time.
The app I am currently building is getting larger every day, and so is the main Activity class! Because my main activity contains a TabHost with a bunch of tabs, it also contains references to all individual view components contained in those tabs. All kinds of listeners are registered on those components so the activity contains some inner and anonymous classes as well. So you could say that this activity now has way too much responsibility! What I was looking for, is a way to separate the main activity into multiple parts, each with its own clear responsibility.
As it turns out, you can create custom components for a single piece of functionality within an Activity. Exactly what I was looking for!
Read the rest of this entry »