If you want to use the new android.support.v7.app.AlertDialog and have different colors for the buttons and also have a custom layout then have a look at my https://gist.github.com/JoachimR/6bfbc175d5c8116d411e
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.custom_layout, null);
initDialogUi(v);
final AlertDialog d = new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle)
.setTitle(getString(R.string.some_dialog_title))
.setCancelable(true)
.setPositiveButton(activity.getString(R.string.some_dialog_title_btn_positive),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
doSomething();
dismiss();
}
})
.setNegativeButton(activity.getString(R.string.some_dialog_title_btn_negative),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
})
.setView(v)
.create();
// change color of positive button
d.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button b = d.getButton(DialogInterface.BUTTON_POSITIVE);
b.setTextColor(getResources().getColor(R.color.colorPrimary));
}
});
return d;
}