java - how do you add an item in a list if a user presses yes button in an alert dialog box and don't add it if he presses no -
i making app in if user selects submenu item pop alert dialog asks confirmation whether wishes save item in list , saves if presses yes , doesn't add if presses no.
you can use show alert:
alertdialog.builder builder = new alertdialog.builder(this); builder.setmessage("are sure this?").setcancelable(false).setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dosomething(); dialog.cancel(); } }).setnegativebutton("no", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.cancel(); } }); alertdialog alert = builder.create(); alert.show();
Comments
Post a Comment