简体   繁体   English

Android ProgressDialog线程

[英]Android ProgressDialog thread

How to show ProgressDialog in separate UI thread? 如何在单独的UI线程中显示ProgressDialog?

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... 使用处理程序,线程,AsyncTask并没有帮助...

Is there any way to run ProgressDialog in separate thread and main (long) operation in main thread? 有什么方法可以在单独的线程和主线程中的主(长)操作中运行ProgressDialog?

Thanks, 谢谢,

There is only one UI thread. 只有一个UI线程。 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. 恐怕您必须在后台和UI线程的进度栏中运行它。

You might have to do a bit redesigning to achieve that. 您可能需要做一些重新设计才能达到目的。 You can use callbacks to get rid of the return values. 您可以使用回调来摆脱返回值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM