0
I have this XML file:
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/ic_carro"
android:layout_alignBottom="@+id/mmarker_snippet"
android:layout_alignParentTop="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/marker_titulo"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView"
android:layout_toEndOf="@+id/imageView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="@+id/mmarker_snippet"
android:layout_below="@+id/marker_titulo"
android:layout_alignLeft="@+id/marker_titulo"
android:layout_alignStart="@+id/marker_titulo" />
</RelativeLayout>
And the code for:
mapa.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoContents(Marker marker) {
if (janela == null) {
janela = getLayoutInflater().inflate(R.layout.info_window, null);
janela.setLayoutParams(new RelativeLayout.LayoutParams(200, RelativeLayout.LayoutParams.WRAP_CONTENT));
TextView markerTitulo = (TextView) findViewById(R.id.marker_titulo);
markerTitulo.setText(marker.getTitle());
TextView markerSnippet = (TextView) findViewById(R.id.mmarker_snippet);
markerSnippet.setText(marker.getSnippet());
}
return janela;
}
@Override
public View getInfoWindow(Marker marker) {
return null;
}
});
NB: janela
refers to a View
I declared in the same class.
But when I run the app, every time I click on the marker, I get a Nullpointerexception and I don’t understand why.