您可以使用 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...
}