Codename One - 对话框按钮

时间:2016-01-08 04:38:39

标签: codenameone

场合

我手动将以下Dialog添加到GUI构建的应用程序中:

Dialog.show("Delete","Are you sure?","Yes","No")

当用户按下“是”时,应用程序会从列表中删除项目

问题

我应该在哪里加入“删除”代码?我是否需要动作侦听器来实现这些操作?

1 个答案:

答案 0 :(得分:4)

Dialog可以返回布尔值(true或false),将代码改为使用if statement

if (Dialog.show("Delete","Are you sure?","Yes","No")) {
    //add the code to delete item here
}