Android MapView Overlay That Does Always Keeps An OverlayItem Selected?

- 1 answer

I want to add an ItemizedOverlay to a MapView that always keeps one OverlayItem as the selected one. I indicate this by using a StateListDrawable with two different marker drawables.

But right now, whenever I tap on the map and not hitting a marker, the last selected item will get deselected. But I always want to keep the last item selected until a new one is hit.

I already tried to intercept e.g. onTap, but this only lets me completely disable the tap handling. This means now I can't even select another marker anymore.

Any suggestions what to do about this?



I got an answer on the android developer ml. I think this would the correct solution, if the mapview wouldn't have a bug in itself.

Here the proposed solution:

Keep track of the last selected item. In onTap() if the currentFocus() is null, setFocus() to the last selected item you saved. If it's not null, update your reference.

You can also use the same idea but using the OnFocusChangeListener on the ItemizedOverlay to determine if a new item has been focuses or not.