I wish to have a single class which all of my Activity classes extend. I have ListActivities, Activities, MapActivities, TabActivities, etc in my App.
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:MenuScreenwhich extendsBaseListActivity BaseListActivityextendsListActivityBaseListActivitycontains methods and fields which i want all my activities to have access toI have another
Activity:HomeScreenwhich extendsBaseActivityBaseActivityextendsActivityBaseActivitycontains the same methods and fields which are in my otherBase[<type>]Activityclasses(such asBaseListActivity)
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?