gpt4 book ai didi

android - postInvalidate() 有什么作用?

转载 作者:IT老高 更新时间:2023-10-28 13:22:18 25 4
gpt4 key购买 nike

postInvalidate()函数在Android中有什么用?我在很多地方都看到过这个功能。当我用 Google 搜索时,我得到了这么多:

postInvalidate-- post an invalidate request on the UI-thread

我不知道那里的“无效请求”是什么意思。有人可以详细解释这里发生了什么吗?

最佳答案

从 View 类派生的每个类都有 invalidatepostInvalidate 方法。如果 invalidate 被调用,它会告诉系统当前 View 已经改变,应该尽快重绘。由于此方法只能从您的 UIThread 调用,因此当您不在 UIThread 中并且仍想通知系统您的 View 已更改时,需要另一个方法。 postInvalidate 方法从非 UIThread 通知系统,并尽快在 UIThread 上的下一个事件循环中重绘 View。也是briefly explained在 SDK 文档中。

只需比较 invalidatepostInvalidate

关于android - postInvalidate() 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5521596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com