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:
public void onClick(DialogInterface dialog, int which) {
if (options[which] == "Manage") {
//Do smtg
} else {
dialog.dismiss();
final AlertDialog alert;
AlertDialog.Builder dialog2 = new AlertDialog.Builder(CategoryPage.this);
alert = dialog2.create();
alert.setTitle("Delete " + title + "?");
alert.setMessage("Are you sure you want to delete this category?");
alert.setButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(CategoryPage.this, "YESS", Toast.LENGTH_LONG).show();
}
});
alert.setButton2("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
alert.dismiss();
}
});
alert.show();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With