2

我想添加一个 StateListDrawable 作为标记图标,如下所示:

MarkerOptions marker = new MarkerOptions().position(xy).title("Marker").icon(BitmapDescriptorFactory.fromResource(R.drawable.state));

但是,它给了我一个空指针异常,有什么解决方法吗?

12-06 18:52:51.152: E/AndroidRuntime(3264): Caused by: java.lang.NullPointerException
12-06 18:52:51.152: E/AndroidRuntime(3264):     at maps.y.bw.a(Unknown Source)
12-06 18:52:51.152: E/AndroidRuntime(3264):     at maps.y.bw.b(Unknown Source)
12-06 18:52:51.152: E/AndroidRuntime(3264):     at maps.y.bw.a(Unknown Source)
12-06 18:52:51.152: E/AndroidRuntime(3264):     at maps.y.ae.addMarker(Unknown Source)
12-06 18:52:51.152: E/AndroidRuntime(3264):     at com.google.android.gms.maps.internal.IGoogleMapDelegate$Stub.onTransact(IGoogleMapDelegate.java:167)
12-06 18:52:51.152: E/AndroidRuntime(3264):     at android.os.Binder.transact(Binder.java:279)
12-06 18:52:51.152: E/AndroidRuntime(3264):     at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.addMarker(Unknown Source)
12-06 18:52:51.152: E/AndroidRuntime(3264):     at com.google.android.gms.maps.GoogleMap.addMarker(Unknown Source)

谢谢 !

4

0 回答 0