什么的区别 Activity.runOnUiThread
和 View.post
,可能有人,请解释一下?
What's the difference between Activity.runOnUiThread
and View.post
, could someone, please, explain?
有没有真正的区别,不同之处在于 View.post
是有用的,当你没有直接访问活动。
There is no real difference, except that the View.post
is helpful when you don't have a direct access to the activity.
在这两种情况下,如果没有对UI线程,Handler#post(Runnable)将被称为幕后。
In both cases, if not on UI thread, Handler#post(Runnable)
will be called behind the scenes.
由于CommonsWare在注释中提到的,这两者之间的差异 - 对UI线程调用时,活动#runOnUiThread
将调用运行
方法直接,而查看#交
将发布可运行
队列(如呼叫在处理程序#交
)
As CommonsWare mentioned in the comment, there is a difference between the two - when called on Ui thread, Activity#runOnUiThread
will call the run
method directly, while View#post
will post the runnable
on the queue (e.g. call the Handler#post
)
最重要的一点IMO是,都具有相同的目标,而对于谁使用它,不应该有差别(和实现可能在未来改变)。
The important point IMO is that both have the same goal, and for whoever use it, there should be no difference (and the implementation may change in the future).
上一篇:注入呼叫上行音频的Snapdragon MSM8960系统芯片芯片、音频、系统、Snapdragon
下一篇:应用轰然试图用RecyclerView在Android 5.0时,试图用、RecyclerView、Android