FragmentActivity with a Fragment Containing a MapView

狂风中的少年 提交于 2019-12-11 03:33:31

问题


I know there are a few questions like this but what I'm looking for is slightly different the way I see it.

THE PROBLEM

I have one Activity and I am only ever going to have one Activity.

I do however have multiple Fragments; one of which contains a MapView.

I have successfully got this working in API level 3.0 and greater. However, the problems start when I want to go lower than this using the compatibility library as I then need to make my Activity extend FragmentActivity to get Fragments to work and then I obviously lose the ability to also extend MapActivity

THE QUESTION

How can I use the Compatibility Support Library to enable the use of Fragments and a MapView within the same Activity?

Any help would be greatly appreciated.

P.S I personally think it's ridiculous they didn't include support for this within the Compatibility Support Library.


回答1:


I've done exactly this! Using this:

https://github.com/petedoyle/android-support-v4-googlemaps

It took some time, but with this, I've been able to have Fragments and a MapView inside the same Activity down to 2.3 (probably lower, as well). You basically get the jar from that github site, which is called android-support-v4-r7-googlemaps.jar, and use that instead of the default support library. With that, your main activity still extends FragmentActivity (which is extending MapActivity in the background).

There should be a readme at that same link for further direction.



来源:https://stackoverflow.com/questions/11829782/fragmentactivity-with-a-fragment-containing-a-mapview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!