How do I change the colour of a radio button? The image below shows that the radio buttons are blue by default but I would like to change this.
My code is:
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
alertDialogBuilder.setCustomTitle(promptsView);
alertDialogBuilder.setItems(frequencyName, null);
// alertDialogBuilder.setTitle("SELECT FREQUENCY");
alertDialogBuilder.setSingleChoiceItems(frequencyName, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
selectedFre = frequencyName[i];
}
});
alertDialogBuilder
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
txtFrequency.setText(selectedFre);
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
Create corresponding style for AlertDialog
<style name="MaterialThemeDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/action_bar_background</item>
</style>
Create AlertDialog.Builder
using that style like below example.
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
getActivity(),
R.style.MaterialThemeDialog);
alertDialogBuilder.setTitle(R.string.image_resolution);
alertDialogBuilder.setSingleChoiceItems(R.array.quality_labels, getPosition(), this);
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.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