The framework will not draw Views that are not in the invalid region, and also will take care of drawing the Views background for you.You can force a View to draw, by calling invalidate().
/**
* Invalidate the whole view. If the view is visible, {onDraw} will
* be called at some point in the future. This must be called from a
* UI thread. To call from a non-UI thread, call {postInvalidate()}.
*/
调用invalidate会调用onDraw方法,如果不是UI线程可以调用postInvalidate
一般情况下
当TextView的内容改变时,会自动刷新,当TextView的布局改变时,会自动刷新,当地调用invalidate时,同样会刷新。另外post.invalidate()也可以实现刷新。
若要刷新TextVew,调用setMessage
用 Handler 的 public void handleMessage( Message msg ) 处理线程刷新问题 |