Adding a button to a custom InfoWindowAdapter view that can register clicks

Instead, listen for marker click events with OnMarkerClickListener and display your own complete view directly. It may be a bit more work to anchor it to the location of the marker, however. Try PopupWindow with showAtLocation(View parent, int gravity, int x, int y)


Maybe you can set a customize AlartDialog in InfoWindowClickListener to switch something event

map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {          
        public void onInfoWindowClick(Marker marker) {
            String[] items={"onefunction","twofunction"};
            AlertDialog.Builder itemDilog = new AlertDialog.Builder(context);
            itemDilog.setTitle("");
            itemDilog.setCancelable(false);
            itemDilog.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    switch(which){
                    case 0:{
                            onefunction();
                            }break;
                    case 1:{
                            twofunction();
                            }break; 
                    }

                }
            });
            itemDilog.show();

        }
    });

While you can set an info window to be an arbitrary view using GoogleMap.setInfoWindowAdapter(), the info window that is rendered on the map is not a live view. Instead, it is a snapshot of the view at the time the view was returned by the adapter (see here). So, unfortunately it doesn't behave like a standard view once it is placed on the map.