我只想在解析Lwuit J2ME应用程序中的一些Xml时显示一个加载屏幕。我看到有很多例子,比如滑块和量规,我找到了这个简单的代码,但我不知道如何在解析操作时显示对话框。如果我使用dialog.showDialog();它将阻止UI
passenger p = new passenger();
p.start();
synchronized (p) {
System.out.println("passenger is waiting for the bus ");
try {
p.wait();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
System.out.println("passenger got notification");
// I think that i must use the loading thing here but i don't know
// what to do.
}
System.out.println("after "+p.total+" time");
class passenger extends Thread {
int total = 0;
public void run() {
synchronized (this) {
System.out.println("wait .... ");
for (int i = 0; i <= 3000; i++){
total = total + i;
System.out.println(total+"");
}
System.out.println("passenger is given notification call");
notify();
}
}
您需要在后台线程中进行解析,然后在解析完成后处理对话框。