I am trying to add an alertdialog within an alertdialog.But not able to see the second alertdialog..please help me here is my code shown
AlertDialog alertDialog = new AlertDialog.Builder(myclass.this).create();
alertDialog.setTitle("First alert");
alertDialog.setMessage("first alert press");
alertDialog.setButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
dialog.cancel();
AlertDialog alertDialog1 = new AlertDialog.Builder(myclass.this).create();
alertDialog1.setTitle("second alert dialog");
alertDialog1.setMessage("second alert dialog details");
alertDialog1.setButton("Scan Another", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}}); }
It is gonna be a late answer but you can create an AlertDialog inside onClickListener just like this:
I found the way might be it will be helpful for someone so thats why i am sharing:
The
txtSubmit
function calling from the onClick event listener. Also for the second alert dialog need to open I have to passHere, we have to bind the this event using
className
When we click on the yup button in the first dialog,it shows the second dialog that insides in the first one
AlertDialogs aren't supposed to let another AlertDialog to be open. If it is really what you want, then change your main AlertDialog to Dialog. This way you can manually add the buttons and functionality you require for manage the secondary AlertDialog