Cory, TreKing,

I've found myself doing something similar, actually subclassing
MapActivity, Activity, to do this.  So to answer TreKing's question,
yes, you'd need one of each type to do this ("BaseActivity",
"BaseMapActivity" "BaseListActivity" ... ??).
To maintain common functionality, they are composed with a common
delegate class whose methods are then called from each of the common
base classes.  Activity Classes which inherit from these common base
classes can then go about their business (mostly) ignorant of
implementation details of their superclasses.

It's not really pretty though and I'm curious what other approaches
have been used in the wild, to share some common functionality across
different Activity classes of different types; I feel this design can
be re-factored into something better and more scalable/maintainable.
For my purposes right now, it's fine, and I'm sure I will re-factor it
soon enough, when time and priorities allow.  But curious what other
developers have done to share common code across different Activities
which are all derived from different parent classes.  I'm making an
assumption that we're talking about common code that we want to
execute during activity lifecycle methods and activity related
methods?


On May 12, 1:06 pm, TreKing <treking...@gmail.com> wrote:
> On Wed, May 11, 2011 at 1:08 PM, Cory Kaufman <allspirits...@gmail.com>wrote:
>
> > It's worked out well for me to create a base class that extends Activity
> > that all of my other activities extend, so I have a central
> > place to put common functionality.
>
> What happens when you need a MapActivity? Or ListActivity? Or
> ExpandableListActivity? Or ... ?
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to