first of all, have tell have searched here , on google , can't find easy way (im newbie on this), need please
i have button, removes friend remote database:
removebutton.setonclicklistener(new onclicklistener() { public void onclick(view v) { con.deletepermission(settings.getstring("login",""),bundle.getstring("email")); finish(); toast.maketext(getapplicationcontext(), getstring(r.string.friendsuccessfullyremoved), toast.length_long).show(); } });
i want show simple "are sure? yes or not" dialog 2 buttons (yes , not) , when user press yes, have called code:
con.deletepermission(settings.getstring("login",""),bundle.getstring("email")); finish(); toast.maketext(getapplicationcontext(), getstring(r.string.friendsuccessfullyremoved), toast.length_long).show();
exist's easy way it?
thanks
edit: try this: http://developer.android.com/guide/topics/ui/dialogs.html doesn't works, nothing happens when press button, no dialog appear
my new code:
bundle = this.getintent().getextras();//get intent & bundle passed x builder = new alertdialog.builder(this); removebutton.setonclicklistener(new onclicklistener() { public void onclick(view v) { /* con.deletepermission(settings.getstring("login",""),bundle.getstring("email")); finish(); toast.maketext(getapplicationcontext(), getstring(r.string.friendsuccessfullyremoved), toast.length_long).show(); */ builder.setmessage("are sure?") .setcancelable(false) .setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { con.deletepermission(settings.getstring("login",""),bundle.getstring("email")); finish(); toast.maketext(getapplicationcontext(), getstring(r.string.friendsuccessfullyremoved), toast.length_long).show(); } }) .setnegativebutton("no", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.cancel(); } }); alertdialog alert = builder.create(); } });
from documentation:
creates alertdialog arguments supplied builder. not show() dialog. allows user processing before displaying dialog. use show() if don't have other processing , want created , displayed.
that means, need call show()
.
Comments
Post a Comment