I have a problem. How I can extends for two activities. I have a activity which must extends two other activities, but I can’t extends about two activities. How I can do this another way?
I need this because one activity extends Activity, but in this activity must extends MapActivity too because I’m using mapView.
I have a problem. How I can extends for two activities. I have a
Share
In java you can not extend two classes at the same time. There are several approaches:
You can have one of the classes as a member field (lets call this
A) and the other one (lets call thisB) to be extended. Thus you will have access to the the private and protected methods ofBand to all public methods ofB. After all the main reason of extending anActivityis to get allContext‘s methods. From then on your own activities are just adding up methods. However, you can use them even without inheriting.If it is possible you can make
AextendBand then make your new activity extend onlyA. Thus all the methods of both activities will be inherited.EDIT After your edit I can say you are already in case 2 of my explanation.
MapActivityis anActivityby itself. You need not extend both. Extend justMapActivity.