Reputation: 1986
I just want to show a loading screen while parsing some Xml in my Lwuit J2ME Application. I saw that there are many examples such as the slider and the gauge,and i found this simple code but i don't know how to show the dialog while the parsing operation. If i used dialog.showDialog(); it will block the 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();
}
}
Upvotes: 1
Views: 559
Reputation: 52770
You need to do your parsing in a background thread and then dispose the dialog when you are done.
Upvotes: 3