android - AlertDialog not showing inside OnClickListener -
i want display alertdialog
inside onclicklistener
. alertdialog
not showing when use following code inside onclicklistener
. great.
final alertdialog alertdialog = new alertdialog.builder(myclass.this).create(); alertdialog.settitle("info:"); string alert1 = "first name: " + fname; string alert2 = "surname: " + sname; string alert3 = "id: " + tid; string alert4 = "password: " + tpassword; alertdialog.setmessage(alert1 +"\n"+ alert2 +"\n"+ alert3+"\n" + alert4); alertdialog.setbutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { startactivity(intent); } }); alertdialog.show(); }});
add below code inside onclicklistner :
alertdialog.builder dialog1 = new alertdialog.builder(this); dialog1.settitle("info:"); string alert1 = "first name: " + fname; string alert2 = "surname: " + sname; string alert3 = "id: " + tid; string alert4 = "password: " + tpassword; dialog1.setmessage(alert1 + "\n" + alert2 + "\n" + alert3 + "\n" + alert4); dialog1.setbutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { startactivity(intent); } }); dialog1.show();
Comments
Post a Comment