开发者

Why invalidate must be called by UI thread

开发者 https://www.devze.com 2023-03-08 01:02 出处:网络
Anyone know why invalidate must be called by UI thread? 开发者_运维百科 As in Java Swing, the repaint function can be called by both non-UI thread and UI thread. repaint is performing a very similar

Anyone know why invalidate must be called by UI thread?

开发者_运维百科

As in Java Swing, the repaint function can be called by both non-UI thread and UI thread. repaint is performing a very similar task as invalidate (this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.).


No, they are not the same. There's also an invalidate method in Swing, and that one does also require the invoker to be invoking it from the EDT/Swing/UI-thread.

Looks like the equivalent to repaint on Android is postInvalidate


When we call invalidate from a UiThread it tells the application to redraw the view when the main thread goes idle.So when we call invalidate ,it basically schedules the views to be drawn again when all other immediate work is completed.If you want redraw the view in a separate thread other than UiThread then use postInvalidate().

0

精彩评论

暂无评论...
验证码 换一张
取 消