您好我在我的应用程序中使用基于片段的布局 – 一切都很顺利 – 我使用一个特殊的MapFragment和一些其他PageFragments来显示数据. MapFragment工作正常 – 地图显示没有问题,我可以在上面绘
现在我想在我的一个PageFragments中添加一个小的地图视图.
我尝试过:
<com.google.android.gms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00000000" android:clickable="true" map:uiCompass="true" map:uiZoomControls="true" map:zOrderOnTop="true" > </com.google.android.gms.maps.MapView>
没有XML错误等.应用程序正常工作 – 我的PageFragment正确显示,但地图视图仍然是空白.有任何想法吗?
您必须从Activity或Fragment转发生命周期方法才能使MapView正常工作.特别是:> onCreate(Bundle)
> onResume()
> onPause()
> onDestroy()
> onSaveInstanceState()
> onLowMemory()
http://developer.android.com/reference/com/google/android/gms/maps/MapView.html
如果有人错过了,这对Google Maps API v2有效.如果你没有覆盖这些方法,你仍然可以看到地图网格,地图控件等,但是虚构的地图是不可见的.