What is the use of the postInvalidate()
function in Android? I have been seeing this function in a lot of places. When I Googled, I came out with this much:
By this method (postInvalidate()
), you can invalidate a View
from non-UI threads. To invalidate a View
from UI-thread use invalidate()
method.
The invalidation means, that the View.onDraw(Canvas)
method will we called at some point in the future (not immediately) to redraw whole View
(if the View
is visible).
Android is redrawing View
s automaticly, but sometimes is necessary to tell: "Hey, this View
has been changed, redraw it as fast as possible."
More at:
http://developer.android.com/guide/topics/ui/how-android-draws.html
http://developer.android.com/reference/android/view/View.html#invalidate%28%29