android高德地圖TabHost切換Activity時地圖卡死

問題描述:TabHost切換Activity,每個activity中都包含一個高德地圖,首次進入第一個顯示的地圖可以使用,切換到第二個時地圖卡死不能操作。

 

解決辦法:把MapView改成TextureMapView

1.把layout佈局中的MapView改掉

<com.amap.api.maps.MapView
        android:id="@+id/activity_map_map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

改成

<com.amap.api.maps.TextureMapView
        android:id="@+id/activity_map_map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

2.把代碼中的MapView改掉

 MapView mMapView;

改成

TextureMapView mMapView;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章