Hi, I want to add marker information to my Google map in an Android app. Therefore, I have an added custom info window, and it has an image and a button. My goal, after clicking the marker, then displays an information window, and then after the user clicks a button in the window, closes the information window and does some action after the button is clicked. But I canβt determine when the user clicks a button in the token window. This is my code. Plz tell me where this is wrong in my code.
googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker arg0) {
final View infoview = getLayoutInflater().inflate(R.layout.info_window,
null);
LatLng latLng = arg0.getPosition();
Button pickMe = (Button)infoview.findViewById(R.id.pickme);
pickMe.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Requested Send", Toast.LENGTH_SHORT).show();
}});
return infoview;
}
});
And this is my customInfo-window XML file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Sajith Vijesekara"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:src="@drawable/driver" />
<Button
android:id="@+id/pickme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:text="Pick Me" />
</LinearLayout>
</LinearLayout>
Thanks Sajith