【问题标题】:Waiting screen in Lwuit J2MELwiit J2ME 中的等待屏幕
【发布时间】:2012-09-03 20:05:16
【问题描述】:

我只想在我的 Lwiit J2ME 应用程序中解析一些 Xml 时显示一个加载屏幕。 我看到有很多例子,例如滑块和仪表,我找到了这个简单的代码,但我不知道如何在解析操作时显示对话框。 如果我使用 dialog.showDialog();它会阻止用户界面

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

【问题讨论】:

    标签: multithreading java-me loading lwuit


    【解决方案1】:

    您需要在后台线程中进行解析,然后在完成后处理对话框。

    【讨论】:

    • 谢谢,你能告诉我是否可以使用上述任何代码来帮助我做到这一点。或者还有其他方法来实现等待屏幕?
    • 您正在 EDT 上调用 wait() ,这有点否定了打开新线程的想法。显示等待对话框后,您需要释放 EDT。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多