BlackBerry 非 UI 点击事件侦听器

发布于 2024-12-13 01:56:17 字数 444 浏览 0 评论 0原文

我正在我的应用程序中运行以下代码。执行此代码时,它会显示全局屏幕警报(确定、取消)。

final Dialog _dialog = new Dialog(Dialog.D_OK_CANCEL, "Message", Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
Application.getApplication().invokeAndWait(new Runnable() {
    public void run() {
        ui.pushGlobalScreen(_dialog, 0, UiEngine.GLOBAL_QUEUE);
    }
});

如果用户单击“确定”,那么我想去其他课程。其他什么也没有。这是怎么做到的?我怎样才能知道点击了哪个按钮?

I am running the following code in my application. When this code is executed, it displays a global screen alert (OK, Cancel).

final Dialog _dialog = new Dialog(Dialog.D_OK_CANCEL, "Message", Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
Application.getApplication().invokeAndWait(new Runnable() {
    public void run() {
        ui.pushGlobalScreen(_dialog, 0, UiEngine.GLOBAL_QUEUE);
    }
});

If the user clicks 'OK', then I want to go some other class. Else nothing. How is this done?. How can I find out which button was clicked ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的鱼塘能养鲲 2024-12-20 01:56:17

实现DialogClosedListener接口并重写dialogClosed()方法。

此代码示例将为您提供帮助。

在你的 _dialog.show(0); 之后设置对话框关闭的监听器。

_dialog.setDialogClosedListener(new MyDialogClosedListener());

现在创建内部类如下:-

 public class MyDialogClosedListener implements DialogClosedListener
    {

    public void dialogClosed(Dialog dialog, int choice) 
    {
        if(dialog.equals(_dialog))
        {
            if(choice == -1)
            {

            }
            if(choice == 1)
            {
                your code to implement
            }
            else if(choice == 2)
            {

                your code to implement  
            }

        }


    }

}

Implement DialogClosedListener interface and override the dialogClosed() method.

this code example will help you.

after your _dialog.show(0); set the listener for dialog close.

_dialog.setDialogClosedListener(new MyDialogClosedListener());

now make inner class as follows:-

 public class MyDialogClosedListener implements DialogClosedListener
    {

    public void dialogClosed(Dialog dialog, int choice) 
    {
        if(dialog.equals(_dialog))
        {
            if(choice == -1)
            {

            }
            if(choice == 1)
            {
                your code to implement
            }
            else if(choice == 2)
            {

                your code to implement  
            }

        }


    }

}
我是有多爱你 2024-12-20 01:56:17

您正在寻找的代码如下:

string confirmationDialogMessage = "Are you sure you want to do this?";
if (Dialog.ask(Dialog.D_OK_CANCEL, confirmationDialogMessage) == Dialog.OK) {
  //do something
}
else {
  //do nothing
}

不需要需要创建Dialog的新实例或实现DialogClosedListener接口。

(请参阅http:// /www.blackberry.com/developers/docs/4.0.2api/net/rim/device/api/ui/component/Dialog.html 了解更多信息)。

The code you're looking for is this:

string confirmationDialogMessage = "Are you sure you want to do this?";
if (Dialog.ask(Dialog.D_OK_CANCEL, confirmationDialogMessage) == Dialog.OK) {
  //do something
}
else {
  //do nothing
}

You don't need to create a new instance of Dialog or implement the DialogClosedListener Interface.

(see http://www.blackberry.com/developers/docs/4.0.2api/net/rim/device/api/ui/component/Dialog.html for additional information).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文