本文介绍了安卓:ProgressDialog不旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有得到ProgressDialog轮毂旋压问题。这里是我的code:
I am having problems getting the ProgressDialog wheel spinning. Here is my code:
final ProgressDialog dialog = ProgressDialog.show(this, "", "Loading...", true, false);
Thread thread=new Thread(new Runnable(){
public void run(){
runOnUiThread(new Runnable(){
@Override
public void run() {
if(dialog.isShowing())
// starts a foreground service, does database stuff,
// sets up a spinner with values
dialog.dismiss();
}
});
}
});
thread.start();
一切按计划进行,我得到的ProgressDialog,事情发生在后台,一旦设置,ProgressDialog消失 - 唯一的问题是,在ProgressDialog动画不旋转,pretty多少使之无用
Everything goes as planned, I get the ProgressDialog, stuff happens in the background and once set, ProgressDialog goes away - the only problem is that the animation in ProgressDialog is not spinning, pretty much rendering it useless.
我在做什么错了?
推荐答案
在code你这里省略了
The code you omitted here
// starts a foreground service, does database stuff,
// sets up a spinner with values
必须这样做,阻止UI线程的东西。只要把它们外 runOnUiThread()
方法。
Thread thread=new Thread(new Runnable(){
public void run(){
// starts a foreground service, does database stuff,
// sets up a spinner with values
runOnUiThread(new Runnable(){
@Override
public void run() {
if(dialog.isShowing())
dialog.dismiss();
}
});
}
});
这篇关于安卓:ProgressDialog不旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!