如何提高在AsyncTask的举杯,提示我用的活套 [英] How to raise a toast in AsyncTask, I am prompted to used the Looper
问题描述
我得的AsyncTask在后台完成的任务。在某些时候,我需要发布的东西是完成了一个敬酒。
I have tasks completed by AsyncTask in background. At some point I need to issue a Toast that something is completed.
我试过,我失败了,因为
产生的原因:java.lang.RuntimeException的:内螺纹已经不叫尺蠖prepare无法创建处理程序()
I've tried and I failed because
Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
我怎么能这样做?
推荐答案
onPostExecute - 执行UI线程
要么
publishProgress()
;在doinbackground和
onPostExecute - executes on UI thread
or
publishProgress()
; in your doinbackground and
protected void onProgressUpdate(Integer... progress) {
}
<一个href="http://developer.android.com/reference/android/os/AsyncTask.html">http://developer.android.com/reference/android/os/AsyncTask.html
这篇关于如何提高在AsyncTask的举杯,提示我用的活套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!