I am trying to set the font of the POSITIVE_BUTTON
in my AlertDialog
to monospace
but the font doesn't change. Here is the code:
// Title text
TextView settingsTitle = new TextView(this);
settingsTitle.setText("Settings");
settingsTitle.setPadding(20, 20, 20, 20);
settingsTitle.setTextSize(20);
settingsTitle.setTypeface(Typeface.MONOSPACE);
AlertDialog settingsDialog = new AlertDialog.Builder(this)
.setCustomTitle(settingsTitle)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// continue with delete
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
Typeface standardFont = Typeface.MONOSPACE;
Button positiveButton = settingsDialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setTypeface(standardFont);