与 imageview、textview 等 View 相关的 post 方法的主要用途是什么
new View(Context).post(runnable)
举个例子,我们将不胜感激:)
最佳答案
来自 API 文档:
Causes the Runnable to be added to the message queue. The runnable will be run on the user interface thread. This method can be invoked from outside of the UI thread only when this View is attached to a window.
看起来像:如果您想在另一个线程中更新 View ,您可以简单地使用 post
方法来更新 View 。虽然类型是runnable
,但是它不能在单独的线程中运行,它会像调用普通方法一样在ui线程中运行。
关于android - View的post()方法的主要目的是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10220567/