How to call item click listener for info view adapter?

1.8k Views Asked by At

I want to call some activity by clicking on one button inside info view adapter of marker of google map. is this possible, then how?

My code is like that

// Info view adapter
googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {


     @Override 
     public View getInfoWindow(Marker marker) { 

         view = ((Activity) context).getLayoutInflater().inflate(R.layout.row_browse_jobs_map,null);
         txtDate = (TextView) view.findViewById(R.id.txt_browse_jobMap_placed_date);
         String j_date = "25 JAN, 2015";

         //click listener for button
         txtDate.setOnClickListener(new OnClickListener() {

              public void onClick(View arg0) {
                  Toast.makeText(context, "clicked", Toast.LENGTH_SHORT).show(); 
              } 
         });
         return view; 
     }

     //content wraping
     public View getInfoContents(Marker arg0) {  
         return null; 
     } 
}); 
1

There are 1 best solutions below

3
On

Please check this. I didn't tried this. so i am not sure this is correct or not.

public View getInfoContents(Marker arg0) {
     googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {            
         public void onInfoWindowClick(Marker marker) {
              //your code
            }    
     }
      //your remaining code
 }

Refer this set InfoWindowAdapter show information only for first marker clicked