本文介绍了Handler.post(Runnable的r)和Activity.runOnUiThread(Runnable的R)之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
海兰一切!我想知道是否有与
Hy all!I want to know if there a difference between
new Handler.post(Runnable r);
和
activity.runOnUiThread(Runnable r)
谢谢!
推荐答案
runOnUiThread
基本上适合显示进度对话框或<$ C $之前做一些UI操作C>的AsyncTask 通话。如果您想更新UI线程中的执行过程中,那么最好的方法是创建一个处理程序
将更新你的用户界面,并让该线程继续运行,例如,几秒钟后周期性地更新一个文本视图,说的定时器功能。
runOnUiThread
is basically suited to show a progress dialog or do some UI manipulations before an AsyncTask
call.If you want to update the UI in the middle of a thread execution, then the best approach is to create a Handler
which will update your UI, and let the thread continue running, for example, updating a text view periodically after a few sec, say timer functionality.
这篇关于Handler.post(Runnable的r)和Activity.runOnUiThread(Runnable的R)之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!