Android ProgressDialog 线程
如何在单独的 UI 线程中显示 ProgressDialog?
我有以下代码:
public boolean myMethod() {
// show here ProgressDialog in thread
// long operation, MUST BE NOT in thread, as there's a return value...
return value;
}
使用处理程序,线程,AsyncTask 没有帮助...
有没有办法在单独的线程中运行 ProgressDialog 并在主线程中运行主(长)操作?
谢谢,
How to show ProgressDialog in separate UI thread?
I have the following code:
public boolean myMethod() {
// show here ProgressDialog in thread
// long operation, MUST BE NOT in thread, as there's a return value...
return value;
}
Using Handler, Thread, AsyncTask didn't help...
Is there any way to run ProgressDialog in separate thread and main (long) operation in main thread?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只有一个 UI 线程。切勿在其中运行任何重物。恐怕你必须在后台运行它并在 UI 线程中运行进度条。
您可能需要进行一些重新设计才能实现这一目标。您可以使用回调来消除返回值。
There is only one UI thread. You should never run anything heavy in it. I'm afraid you have to run that in the background and the progress bar in the UI thread.
You might have to do a bit redesigning to achieve that. You can use callbacks to get rid of the return values.