如何在phonegap .exec警告框中创建Phonegap取消按钮?

时间:2012-04-11 04:05:09

标签: cordova cancel-button

如何使用PhoneGap.exec(null, null, "Notification", "activityStart", ["Downloading file","Please wait..."]);

在phonegap中创建取消和确定按钮

2 个答案:

答案 0 :(得分:1)

 navigator.notification.confirm(
        'Do you want to signout and close the application?',  // message
        onConfirm,              // callback to invoke with index of button pressed
        'Sign Out',            // title
        'Sign Out,Cancel'          // buttonLabels
        );

function onConfirm(button) {
    //action for confirmation
}

参考  http://docs.phonegap.com/en/1.2.0/phonegap_notification_notification.md.html

答案 1 :(得分:0)

请指明你想申请phonegap插件的技术(ios,android) 下面是帮助您创建android核心警报框的代码 在执行方法

上调用此函数
 public synchronized void customalertBox(final String callBackId, JSONArray jarray) {
            final AlertDialog showCustomDialog = null;
            final Runnable runnable = new Runnable() {

                @Override
                public void run() {
                    AlertDialog.Builder customdialog = new AlertDialog.Builder(null);
                    showCustomDialog.setButton2("OK", new OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            customalertPLUGIN.success(new PluginResult(
                                    PluginResult.Status.OK, setJSONDataTORETURN),
                                    callBackId);
                            showCustomDialog.dismiss();

                        }
                    });
                    showCustomDialog.setButton2("Cancel", new OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            customalertPLUGIN
                                    .error(new PluginResult(
                                            PluginResult.Status.INVALID_ACTION),
                                            callBackId);
                            showCustomDialog.dismiss();

                        }
                    });
                    showCustomDialog = customdialog.create();
                    showCustomDialog.setCancelable(true);
                    showCustomDialog.show();

                }

            };
        }

希望这会帮助你。留下评论