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

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -