Asaf Nevo
Asaf Nevo

Reputation: 11688

android Google Maps populate() VS invalidate()

i'm building my interactive map and i find myself really confused:

I have an extend of ItemizedOverlay class which i'm managing the overlays.

when shell i use its populate() function in order to update the overlays in the mapView and when should i use invalidate() or postInvalidate() in order to get the map to update.

i found that sometimes this works, and sometimes the other.

if someone will be kind to explain exactly what each of the function does - i will be thanks full because i couldn't find a decent explanation.

Upvotes: 3

Views: 3621

Answers (2)

Raghav Sood
Raghav Sood

Reputation: 82563

populate() should be used when you want to populate the overlay. If all you want to do is have it redrawn, then you should use invalidate() if you're on the UI thread, and postInvalidate() if you're on another thread. The invalidate methods are applicable to any View, be it a button or a text view or anything. They basically tell Android that something has changed related to the View, like the data being shown or the button's state or colour or whatever. Android will then attempt to redraw the View as soon as possible by calling the View's onDraw() method.

Upvotes: 3

Pedro Doria Meunier
Pedro Doria Meunier

Reputation: 11

I always use invalidate() and never had a problem with it... (i.e. always refreshes)

Upvotes: 0

Related Questions