android view怎样刷新

来源:互联网 发布:matlab定义字符串数组 编辑:程序博客网 时间:2024/05/01 09:32

两种方式刷新:

  1. 主线程可以直接调用Invalidate()方法刷新

  2. 子线程可以直接调用postInvalidate()方法刷新。

  3. API的描述是这样的 : Invalidatethe whole view. If the view is visible, onDraw(Canvas) will be called at somepoint in the future. This must be called from a UI thread. To call from anon-UI thread, call postInvalidate().。当Invalidate()被调用的时候,View的OnDraw()就会被调用,Invalidate()必须是在UI线程中被调用,如果在新线程中更新视图的就调用postInvalidate()。

0 0
原创粉丝点击