I have displayed AlertDialog with 2 buttons i.e. Yes and Cancel, here is the code.
final AlertDialog.Builder builder = new AlertDialog.Builder(RiderDetailActivity.this);
builder.setCancelable(false);
builder.setMessage("Are you sure?");
final AlertDialog dialog = builder.create();
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialog.dismiss();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialog.dismiss();
}
});
dialog.show();
This doesn't show yes and cancel button only on samsung galaxy s4

But when i use it with with dialog.setButton it works perfectly
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialog.dismiss();
}
});
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialog.dismiss();
}
});

Note : builder.setPositiveButton and builder.setNegativeButton is creating problem on just Samsung Galaxy S4, for other devices it is working perfectly.
I need to create dialog after setting buttons to builder, but my concern is why it was working with other devices and just creating problem with Samsung Galaxy S4?
Try this way. I hope this will work for you.
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setMessage("Are you sure?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
final AlertDialog dialog = builder.create();
dialog.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