MapFragment in Fragment, alternatives?

后端 未结 8 629
猫巷女王i
猫巷女王i 2020-12-08 10:32

I need your help... I work on it until 3 days. My app is working with fragments. One of these fragments has to display a map from the Google Maps V2 api for Android.

8条回答
  •  误落风尘
    2020-12-08 11:15

    Use MapView instead of MapFragment in your Fragment's layout. Remember to call MapView's lifecycle methods:

    • onCreate(Bundle)
    • onResume()
    • onPause()
    • onDestroy()
    • onSaveInstanceState(Bundle)
    • onLowMemory()

    as described here.

    Btw. you shouldn't be using MapFragment, only SupportMapFragment and support library.

    Edit:

    If you switch to support library, you can use code from comment #1 here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=5064#c1

提交回复
热议问题