how to pass image drawables and text dynamically to the infowindow adapter?

366 views Asked by At

I am working on Google maps.I want to place a source marker, a destination marker and in between I want to place waypoint markers.Each waypoint has individual markers.These three markers are different in their colors.I placed them successfully.The problem is that I want to display the custom image including the text view.I am using the Info Window Adapter and I am getting the imageview with the textview to all the markers.Unfortunately I dont know how to pass the image drawables and text dynamically to the infowindow adapter. Can you help me?

  // Defines the contents of the InfoWindow
    @Override
    public View getInfoContents(Marker arg0) {

        // Getting view from the layout file info_window_layout
        View v = getLayoutInflater().inflate(R.layout.windowlayout, null);

        // Getting the position from the marker
        LatLng latLng = arg0.getPosition();

        // Getting reference to the TextView to set latitude
        TextView tvLat = (TextView) v.findViewById(R.id.tv_lat);

        // Getting reference to the TextView to set longitude
        TextView tvLng = (TextView) v.findViewById(R.id.tv_lng);

        // Setting the latitude
        tvLat.setText("Latitude:" + latLng.latitude);

        // Setting the longitude
        tvLng.setText("Longitude:"+ latLng.longitude);

        // Returning the view containing InfoWindow contents
        return v;

    }
})

if we click on the marker I am able to get this window.How can I pass the image and text dyanamically (differ) from marker to marker???

0

There are 0 answers