Issue
Am doing my android project. I have created the dialog box with YES and NO button. If i click YES a new dialog box should be displayed with options to select. I created the dialog box with options. But couldnt display it when i click YES in the dialog box which i created first. How can i do it? Please help. Thanks.
Here is the code of the dialog box which i created. When i click YES button in this dialog i should display another dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Low Memory\nYou want to send the file to server?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
finish();
}
});
AlertDialog alert = builder.create();
alert.show();
Solution
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Low Memory\nYou want to send the file to server?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
AlertDialog.Builder builder2 = new AlertDialog.Builder(CLASSNAME.this);
builder2.setTitle("hi!");
//etc
builder2.show();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
finish();
}
});
AlertDialog alert = builder.create();
alert.show();
Hope this helps. ;)
Answered By - Aerial