I’ve got an Activity that holds a ListFragment on the left and a SupportMapFragment on the right.
List and Map are both backed by the same data. The visual representation of the data on the Map are Markers.
I want to be able to perform a click on either a list item or a Marker and get the corresponding item in the other visual representation.
Restrictions of the framework and my data are:
-
The Marker class is final and the Marker’s id does not have a modificator. This is why I can’t use the easiest possible way.
-
“It’s important to not hold on to objects (e.g. Marker) beyond the
view’s life. Otherwise it will cause a memory leak as the view cannot
be released.” (see SupportMapFragment) -
Titles of Markers can occur multiple times. This is why the expensive String comparison is not a way I can go.
Does anyone have a working solution for this issue or can provide a nudge in the right direction?
If you want to be able to register to clicks on a Marker, you’ll need to override the
InfoWindowAdapter.You can provide unique information to the title and snippet of a Marker and implement the interface’s methods in this style:
Now you can set the
OnInfoWindowClickListenerand work with the unique information stored there.