0

从这个页面实现加载屏幕时遇到问题

黑莓请等待屏幕超时

它运行良好,但问题是我无法从此代码中获取字符串数据。

这个想法是我想在从 web 服务捕获 json 数据时加载屏幕,并将其作为字符串返回。但是我卡住了,因为下面的代码无法返回数据。

UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run() {
                        UiApplication.getUiApplication().popScreen(thisScreen)

有什么建议吗?

4

1 回答 1

0

您可以使用 anInterface来实现。当您调用该方法时PleaseWaitPopupScreen.showScreenAndWait(Runnable, String)(来自链接BlackBerry Please Wait Screen with Time out),您可以在该方法上添加另一个参数。如果一个接口实例用作第三个参数,则该接口的回调方法可用于通知PopupScreen关闭事件。您可以尝试以下步骤。


创建一个接口,定义回调方法。

interface PopupScreenCloseListener {
    // Invoke this method when PopupScreen gets closed.     
    public void popupScreenClosed();
}


实现接口并将其附加为 的第三个参数showScreenAndWait。还可以在回调方法上获取 PopupScreen 关闭事件通知。

class MyClass implements PopupScreenCloseListener {
    public void showWaitingPopupScreen(final Runnable runThis, String text) {
        // append the interface, PopupScreenCloseListener as third parameter
        PleaseWaitPopupScreen.showScreenAndWait(runThis, text, this);
    }

    public void popupScreenClosed() {
        // listen PopupScreen close event here...
        // and add codes...
    }
}


并修改该方法的当前实现,showScreenAndWait.

public static void showScreenAndWait(final Runnable runThis, String text, final PopupScreenCloseListener listener) {
    // old codes...
    // old codes...
            // Now dismiss this screen
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    UiApplication.getUiApplication().popScreen(thisScreen);

                    // notify PopupScreen close event.
                    if (listener != null) {
                        listener.popupScreenClosed();
                    }

                }
            });
    // old codes...
    // old codes...
}
于 2012-05-03T20:33:46.700 回答