Oct 7, 2010
I wish to have a single class which all of my Activity classes extend. I have ListActivities, Activities, MapActivities, TabActivities, etc in my App.
View 2 Replies
I have many of these different activities in my app, ~12 activities. I want each of them to have the methods which are in the parent class.
Right now, i have created 4 parent activity classes which are extended from a certain activity depending on their type(ListActivity, Activity, MapActivity, TabActivity)
I am creating a lot of redundant code - each of the 4 parent activities has almost identical code, in exception for what class activity it extends.
Here is an example that may clarify what my problem is:
I have an Activity: MenuScreen which extends BaseListActivity BaseListActivity extends ListActivity BaseListActivity contains methods and fields which i want all my activities to have access to I have another Activity: HomeScreen which extends BaseActivity BaseActivity extends Activity BaseActivity contains the same methods and fields which are in my other Base[<type>]Activity classes(such as BaseListActivity)
These methods/fields are copy-pasted to all my Base[<type>]Activity, and seems awfully redundant to me.
Can i create a master activity class which all types of Activity classes can use as its parent? if not, am i stuck with copy and pasting this code and feeling gross/dirty about it?