现在我知道,有很多线程都有这个问题,但我尝试了所有这些并且它只是没有用。问题是我的进度条没有更新。这是我的代码:
private class TwoSecondsThread extends Thread {
int progress = 0;
public TwoSecondsThread() {
}
@Override
public void run() {
while(progress != 2000) {
Log.d("TWO SECONDS", "going to sleep for 100ms");
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
progress += 100;
final ProgressBar pg = startTransactionProgressBar;
// Update the progress bar
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d("TWO SECONDS", "updating progress bar");
pg.setProgress(progress);
}
});
}
}
}
我明白,adnroid SDK中存在错误,但我看到有具有功能progressBar的应用程序。那么让它运作的诀窍是什么呢?
谢谢, 菲利普