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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -