1

I'm wanting to extend both a MapActivity and a FragmentActivity. I know Java doesn't allow multiple inheritance, so how do I do this? I've read something about a 'composite' type, but I've never implemented one so I don't know how to go about doing that.

Someone else HAS to have run into this before, how did you solve it?

EDIT: The reason I want this is because I have 3 activities in tabs; a map, an image gallery, and a settings list view. The code for all three of these "acitivities" is inside one big MapActivity called "Main". Yes I know this is ugly, and not good programming practice, and I don't remember why I wrote it this way. I think it was because I was reading most people recommended NOT having separate activities for separate tabs... which if I decided to split them into separate activities, I wouldn't have this problem anymore.

ahodder
  • 11,353
  • 14
  • 71
  • 114
joshkendrick
  • 3,497
  • 8
  • 38
  • 52
  • 1
    Who says it's not a good idea to use separate Activities? Other than the introduction of fragments, I can't see why they are a bad thing to do. – ahodder Jun 05 '12 at 16:46
  • @AedonEtLIRA - http://stackoverflow.com/questions/1590340/android-tabs-mapview-activities-within-tabs http://stackoverflow.com/questions/1568739/android-why-shouldnt-i-use-activities-inside-tabs – joshkendrick Jun 05 '12 at 17:23
  • I scoured the links you sent, and it definitely appears you are correct, and to that, thanks. That is something I have not run into yet and it makes a hell of a lot of sense. However, since Java does not have multiple inheritance, I would just stick to the multiple activity methodology for now. You can always come back an modify it later, if need be. – ahodder Jun 05 '12 at 17:57

2 Answers2

0

I have no idea why you would want such a thing, but I suppose the easiest solution is something like ActivityGroup, something similar to how TabbedActivity works.

ahodder
  • 11,353
  • 14
  • 71
  • 114
0

I ended up solving this by going in and modifying the source of the Android support package and deploying my app with that. Outlined here, all I did was make FragmentActivity (android.support.v4.app) extend MapActivity. I don't think the reverse works... though maybe, and it would require you having the source of the mapping library you're using (in the case of Google Maps - no go)

Community
  • 1
  • 1
joshkendrick
  • 3,497
  • 8
  • 38
  • 52