I want to create an AlertDialog with buttons that look like this: https://developer.android.com/images/ui/dialogs_regions.png
However, whenever I create an AlertDialog with the AlertDialog.Builder, I end up getting buttons that look like this: https://developer.android.com/images/ui/dialog_buttons.png
How can I change the AlertDialog so that the buttons look like the first example (i.e. taking up the entire bottom of the dialog, with gray divider lines between each button)? Note that I am not trying to change the color of the dialog window, just the way that the buttons appear on it. Ideally, I'd like to do this with just the default android styles and without defining a custom style - is this possible?
Here's the code I use to create and display the AlertDialog:
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle("Include answers in summary?");
alertDialogBuilder.setMessage("You have completed " + String.valueOf(questionsCompleted) + " out of 18 questions. Would you like the summary to include these answers along with the questions?");
alertDialogBuilder.setCancelable(false);
alertDialogBuilder.setPositiveButton("Include", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(getApplicationContext(), SummaryActivity.class);
intent.putExtra("componentNumber", 0);
intent.putExtra("includeAnswers", true);
startActivity(intent);
}
});
alertDialogBuilder.setNegativeButton("Omit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(getApplicationContext(), SummaryActivity.class);
intent.putExtra("componentNumber", 0);
intent.putExtra("includeAnswers", false);
startActivity(intent);
}
});
alertDialogBuilder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
There are three actions in this AlertDialog. Without getting too much into the details, two of the buttons take the user to the same activity summarizing a questionnaire, but with or without their answers included, and the other button cancels the dialog. I know I'm supposed to use the NegativeButton for canceling the dialog, but even though the android developer guide on dialogs says that a neutral button will appear between the positive and negative buttons, I've been getting the order Neutral->Negative->Positive. As a result, I've been getting a dialog with the Omit option on the left side and the Cancel and Include options on the right side, which is extremely unintuitive to me.
I'd like to change the order of the buttons to be Negative->Neutral->Positive and define the negative button as canceling the dialog so that the two buttons which lead to the summary activity are grouped together - is this at all possible?