How to add third button to an Alert Dialog with Example:
Check how to show alert dialog with two buttons
It is veary easy to add three buttons on AlertDialog as shown in below picture
We can add third button on alert popup by setNeutralButton
Check following example code:
[sociallocker]
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Do you want to rate us?") .setTitle("Rate us 5 starts") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Perform some action, yes button is pressed } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); // No button is pressed } }) .setNeutralButton("Remind me later", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Cancel button is pressed } }); builder.create().show();
[/sociallocker]