Je veux juste montrer un écran de chargement tout enanalyser du XML dans mon application Lwuit J2ME. J'ai vu qu'il existe de nombreux exemples tels que le curseur et la jauge, et j'ai trouvé ce code simple mais je ne sais pas comment afficher le dialogue pendant l'opération d'analyse. Si j'ai utilisé dialog.showDialog (); il va bloquer l'interface utilisateur
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();
}
}
Réponses:
3 pour la réponse № 1Vous devez analyser votre contenu dans un fil d’arrière-plan, puis supprimer la boîte de dialogue lorsque vous avez terminé.