【发布时间】:2016-10-09 17:10:27
【问题描述】:
我在片段中使用谷歌地图并在调用 getMap() 时为空,这是我的代码:
在我的 MapViewFragment 中
private GoogleMap mGoogleMap;
在 onCreate() 方法中,我在这一行得到了 null...
mGoogleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
在 fragment_map_view 文件中
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
【问题讨论】:
标签: android google-maps android-layout