Android : Custom InfoWindow for Android google maps issue

on Friday, January 30, 2015


I've created a custom infoWindowAdapter class in my Android app that uses google maps.

The class uses GetInfoContents and an xml file to create the contents of the infoWindow

The xml contains an ImageView and three TextViews, I can manage to add a marker with the custom infoWindow but it will only show two of the three TextViews and no ImageView and I can't figure out why. The strings for the first two TextViews come from .setText(marker.getTitle()); .setText(marker.getSnippet()); and the string for the third is created within getInfoContents.


code:



@Override
public View getInfoContents(Marker marker) {

if (popup == null) {

popup = inflater.inflate(R.layout.infowindow_popup, null);
}

TextView tvTitle = (TextView) popup.findViewById(R.id.title);
tvTitle.setText(marker.getTitle());

TextView tvSnippet = (TextView) popup.findViewById(R.id.snippet) ;
tvSnippet.setText(marker.getSnippet());

String test2 = "test 2";

TextView tvSnippet2 = (TextView) popup.findViewById(R.id.snippet_2) ;
tvSnippet2.setText(test2);

return null;
}

0 comments:

Post a Comment