Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom infowindow in Google map android v2
    primarykey
    data
    text
    <p>I am using Google Map API V2 and i have created a custom <code>InfoWindow</code> for a <code>Marker</code> on map.In this <code>InfoWindow</code> i have a button.</p> <p>My problem is unable to set Onclicklistener/functioning to that Button(Dummy).Any one give me some idea to solve this :</p> <p><img src="https://i.stack.imgur.com/GKLrF.png" alt="enter image description here"></p> <p>Here is code snippet:</p> <pre><code>public class MarkerView extends FragmentActivity implements OnMarkerClickListener,OnInfoWindowClickListener{ private GoogleMap mMap; private Marker chennai; private View infoWindow; @Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.basic_demo); infoWindow=getLayoutInflater().inflate(R.layout.custom_info_contents, null); mMap=((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); chennai=mMap.addMarker(new MarkerOptions().position(new LatLng(13.0810, 80.274)).anchor(2, 1).title("Android").snippet("Snippet").icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher))); mMap.setInfoWindowAdapter(new CustomInfoAdapter()); mMap.setOnInfoWindowClickListener(null); mMap.setOnMarkerClickListener(this); Button dummy=(Button) infoWindow.findViewById(R.id.dummy); dummy.setVisibility(View.VISIBLE); dummy.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MarkerView.this, "Dummy Button", Toast.LENGTH_SHORT).show(); } }); } class CustomInfoAdapter implements InfoWindowAdapter{ @Override public View getInfoContents(Marker arg0) { displayView(arg0); return infoWindow; } @Override public View getInfoWindow(Marker arg0) { return null; } } public void displayView(Marker arg0) { ((ImageView)infoWindow.findViewById(R.id.badge)).setImageResource(R.drawable.arrow); ((ImageView)infoWindow.findViewById(R.id.badge)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MarkerView.this, "Arrow Image", Toast.LENGTH_SHORT).show(); } }); ((TextView)infoWindow.findViewById(R.id.title)).setText(arg0.getTitle()); ((TextView)infoWindow.findViewById(R.id.snippet)).setText(arg0.getTitle()); } @Override public boolean onMarkerClick(Marker arg0) { if(arg0.equals(chennai)){ infoWindow.setClickable(false); } return false; } @Override public void onInfoWindowClick(Marker arg0) { Toast.makeText(MarkerView.this, "Info window", Toast.LENGTH_SHORT).show(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload