Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 717
Asaf Nevo Avatar asked Jan 26 '26 15:01

Asaf Nevo


1 Answers

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.

like image 137
Raghav Sood Avatar answered Jan 28 '26 04:01

Raghav Sood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!