I am trying to make a custom tooltip for my marker on my Google maps on the Android platform.
I tried some stuff and this is what I have for now.
Inflater class:
private class InfoHandler implements GoogleMap.InfoWindowAdapter, View.OnClickListener {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = layoutInflater.inflate(R.layout.tooltip_brewer, null);
TextView tvLat = (TextView) v.findViewById(R.id.tv_title);
TextView tvLng = (TextView) v.findViewById(R.id.tv_snippet);
Button button = (Button) v.findViewById(R.id.btn_button);
tvLat.setText("TestTooltip");
tvLng.setText("TestTooltip 1");
button.setOnClickListener(this);
return v;
}
@Override
public void onClick(View view) {
Log.d(Constants.TAG, "Test 01");
}
}
Connection to the marker:
public void setInfoWindow(LayoutInflater inflater) {
this.layoutInflater = inflater;
map.setInfoWindowAdapter(new InfoHandler());
}
Tooltip XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="snippet" />
</LinearLayout>
<Button
android:id="@+id/btn_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
Now everything works accept I cannot get the click event working on the button in the tooltip. Does somebody have a solution for that?