How do I close an Android alertdialog -


i developing quiz , need user answer questions before proceeding. when user has not answered questions display simple alertdialog informing him or her. problem whatever can't alertdialog close. why isn't dialog.cancel working?`this code:

alertdialog.builder ad = new alertdialog.builder(this);   ad.settitle("unanswered questions");   ad.setmessage("you have not answered questions.");    ad.setpositivebutton("ok", new dialoginterface.onclicklistener() {      public void onclick(dialoginterface dialog, int id) {        dialog.cancel();  }   });   ad.show();  

the alertdialog.builder not contain dismiss() or cancel() method.

it convenience class create dialog, wich have access methods.

here example:

alertdialog.builder builder = new alertdialog.builder(this);   alertdialog alert = builder.create();  alert.show(); 

you can call alert.cancel() method on alert (not builder)


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -