本文共 922 字,大约阅读时间需要 3 分钟。
1> 在 Fragment 增加高德地图的 com.amap.api.maps.SupportMapFragment
android:id ="@+id/roadcondition_map_f"
android:layout_width ="match_parent"
android:layout_height ="match_parent"
class= "com.amap.api.maps.SupportMapFragment" />
调用 getSupportFragmentManager() 返回为空,因此使用代码直接添加
android:id ="@+id/navigation_map_fl"
android:layout_width ="match_parent"
android:layout_height ="match_parent"
android:layout_marginBottom ="60dp" />
<2> 代码使用SupportMapFragment填充布局
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
MapsInitializer. initialize( activity);
catch (RemoteException e)
SupportMapFragment supportMapFragment = new SupportMapFragment();
transaction.replace(R.id. navigation_map_fl , supportMapFragment);
mAMap = supportMapFragment.getMap();
转载地址:http://rngab.baihongyu.com/