I have created two alert Dialogs. I would like the second Alert Dialog to only appear if I click yes on the first Alert Dialog. But both are always showing.
Alert Dialog Code
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
//Yes button clicked
//Would like the second Alert Dialog to Display Now
YesOrNo = "Yes";
break;
case DialogInterface.BUTTON_NEGATIVE:
//No button clicked
YesOrNo = "No";
GIVE.setBackgroundColor(Color.RED);
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you Giving or Teaching for Free?").setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener).show();
if ( YesOrNo == "Yes" ) {
DialogInterface.OnClickListener dialogClickListener1 = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case DialogInterface.BUTTON_POSITIVE:
break;
case DialogInterface.BUTTON_NEGATIVE:
PROBLEM.setBackgroundColor(Color.RED);
}
}
};
AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
builder1.setMessage("Are you Really Happy With Your Current Giving or Teaching For Free?").setPositiveButton("Yes", dialogClickListener1)
.setNegativeButton("No", dialogClickListener1).show();
}
Thanks