I'm creating multiple custom info windows using only one xml layout, all of the info inside the window will be put In programmatically. I am now trying to give the ImageView an image but when I do that for one marker all of the other markers ImageView images become the same, any idea why?

final Bitmap bmp = BitmapFactory.decodeByteArray(data, 0,data.length);
if(postc.getAuthor().getObjectId().equals(ParseUser.getCurrentUser().getObjectId())){
    Marker oldMarker = mapMarkers.get(postc.getObjectId());
    final MarkerOptions MarkerT = new MarkerOptions().snippet(postc.getTContent());
    MarkerT.title(postc.getAuthor().getUsername());
    MarkerT.position(new LatLng(postc.getLat(), postc.getLong()));
    MarkerT.icon(BitmapDescriptorFactory.fromBitmap(bmp));

    final Marker markeri = map.addMarker(MarkerT);
    map.setInfoWindowAdapter(new InfoWindowAdapter(){

        @Override
        public View getInfoContents(final Marker marker) {

           View v = getLayoutInflater().inflate(R.layout.custommarker, null);
           final LinearLayout ll = (LinearLayout)v.findViewById(R.id.ll);

            try {
                 ink(marker.getSnippet(),ll,BitmapFactory.decodeByteArray(postc.getImage().getData() , 0, postc.getImage().getData().length));
            } catch (ParseException e) {
                 // TODO Auto-genmarerated catch block
                 e.printStackTrace();
            }


            return v;

        }

        @Override
        public View getInfoWindow(Marker arg0) {
            return null;        
        }                                     
});

ink:

   TextView title = new TextView(this);
        title.setText(str);
         ll.addView(title);

      ImageView piv = new ImageView(this);
    piv.setImageBitmap(pf);

      ll.addView(piv);

Thanks

Hi!

just you have created only one marker, But try to use for loop to create n markers and can reeplace the image on # marker..,

like

for(i=0;i>postc.length();i++)
{
Marker MarkerT = new Marker();
            MarkerT.title(postc.getPosition(i).getAuthor().getUsername());
            MarkerT.position(new LatLng(postc.getPosition(i).getLat(),                     postc.getPosition(i).getLong()));
            MarkerT.icon(BitmapDescriptorFactory.fromBitmap(postc.getPosition(i).getbmp));

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.