1

I've been following the following thread on Stack Overflow:

custom info window adapter with custom data in map v2

I have seen the answers on the previous comments, and followed them, but I'm not being able to do it.

On the onMarkerClick I'm being able to get the element I associate to the marker on the:

HashMap<Marker, MyObject>

MyObject is the element that contains the data that I want to show on the marker InfoWindow.

What I'm not being able to do is to put the data on the screen. It blows up the application. How can I do it?

I'm using:

TextView markerTitle = (TextView) getActivity().findViewById(R.id.marker_place_name);
markerTitle.setText(MyObject.getName());

The R.id.marker_place_name is like the example tv_lat TextView on the windowlayout.xml on the mentioned thread.

How can I change it's data correctly to be shown on the marker InfoWindow?

On the InfoAdapter getInfoContents() I'm unable to retrieve MyObject.

Community
  • 1
  • 1
Tigger
  • 25
  • 7

1 Answers1

2

When using HashMap<Marker, MyObject> workaround you need to be able to retrieve it in getInfoContents.

If you are doing separate class (and not anonymous one) for InfoWindowAdapter, you would have to send this map via constructor. It's not pretty, so there is also another choice:

You may want to try Android Maps Extensions which adds setData(Object) and getData() to Markers, so you can keep your MyObject with the Marker.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94