我在我的应用程序中使用谷歌地图扩展库,当我将 android 版本更新到 5.0 时,我在行中得到 NullPointerException:
mMap = ((SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map)).getExtendedMap();
findFragmentById(R.id.map) is null 有人知道为什么吗?
谢谢。
布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_horizontal" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.androidmapsextensions.SupportMapFragment" /></RelativeLayout>
日志猫:
12-08 11:56:57.544: E/AndroidRuntime(20846): FATAL EXCEPTION: main
12-08 11:56:57.544: E/AndroidRuntime(20846): java.lang.NullPointerException
12-08 11:56:57.544: E/AndroidRuntime(20846): at com.analyticadesign.eds.MapPage.setUpMapIfNeeded(MapPage.java:422)
12-08 11:56:57.544: E/AndroidRuntime(20846): at com.analyticadesign.eds.MapPage.onActivityCreated(MapPage.java:321)
12-08 11:56:57.544: E/AndroidRuntime(20846): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1794)
...