2012-09-03 33 views
1

我只想在解析Lwuit J2ME應用程序中的一些Xml時顯示加載屏幕。 我看到有很多例子,如滑塊和量表,我發現這個簡單的代碼,但我不知道如何在解析操作時顯示對話框。 如果我使用dialog.showDialog();它會阻止用戶界面Lwuit J2ME中的等待屏幕

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(); 
      } 
    } 

回答

3

您需要在後臺線程中進行解析,然後在完成後處理對話框。

+0

謝謝,你能告訴我,如果我可以使用任何上述代碼來幫助我做到這一點。或者還有另一種方法來實現等待屏幕? – Reham

+0

您正在調用EDT上的wait(),這種否定打開新線程的想法。顯示等待對話框後,您需要釋放EDT。 –