我正在开发我的第一个Androïd应用程序,当我想要显示ProgressDialog以指示进程正在运行时,我遇到问题。 在我的应用程序中,用户通过按下按钮来触发耗时的任务。当用户按下按钮时,我的“OnClickListener”的“OnClick”功能被调用。在此功能中,这里是目前我在做什么:主题和ProgressDialog
- creation and configuration of an instance of the ProgressDialog class,
- creation of a thread dedicated to the time consuming task,
- attempt to display the ProgressDialog using the "show" method,
- start of the thread,
- main Activity suspended (call of the "wait" function)
- wake up of the main Activity by the thread when it is finished
- removal of the ProgressDialog by calling the "dismiss" function.
,一切工作正常(长期任务的结果是正确的),但仍然出现ProgressDialog讷韦尔。我究竟做错了什么?
在此先感谢您花费时间来帮助我。
使用此方法是否满足原始发布者的要求,即暂停主要活动,直到耗时操作完成? – shyamal 2012-06-26 18:34:06
他为什么要这么做? UI线程负责在后台线程运行时显示(动画)进度指示器。 (调用wait()会挂起UI线程,而不是Activity)。如果我正确理解了这个问题,那么该框不包含他的需求,但是他的解决方案会改为尝试。 – user634618 2012-09-06 13:20:54