其实我有同样的问题inflate a view in a custom infowindow 似乎我不能把这个信息窗口扩展到我想要的布局
平台: Android SDK 25 Mapbox SDK com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.2@aar
1.当我点击标记时,会出现弹出窗口,显示app停止
我想给infowindow(我点击标记后的那个)充气但是到目前为止我想使用XML来进行简单的自定义(我愿意接受建议,我仍然需要添加不同的图像对于每个标记。)。我在代码中使用自定义只是为了测试,但我想为那个purporse夸大XML。
`Process: com.viseo.jooboot, PID: 626
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
at com.viseo.poc.jooboot.ui.activity.MapActivity$addCustomInfoWindowAdapterTest$1.getInfoWindow(MapActivity.kt:204)
at com.mapbox.mapboxsdk.annotations.Marker.showInfoWindow(Marker.java:221)
at com.mapbox.mapboxsdk.maps.MapboxMap.selectMarker(MapboxMap.java:1610)
at com.mapbox.mapboxsdk.maps.MapView$GestureListener.onSingleTapConfirmed(MapView.java:1946)
at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:300)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)`
mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(@NonNull Marker marker) {
View v = getLayoutInflater().inflate(R.layout.test_infowindow, null);
ImageView test = (ImageView) v.findViewById(R.id.iv_item_bg_jobinfo);
if (marker is JobInfoMarker) {
iv_item_bg_jobinfo.setImageResource(R.drawable.jobimage_default)
}
return v;
}
});
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_item_container_jobinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_item_bg_jobinfo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="end"
android:adjustViewBounds="true"
android:contentDescription="@string/tweet_image" />
</LinearLayout>