2

ListPreferenceHey I'm using PreferenceActivity and added radio button to it using ListPreference. The problem is that listPreference uses it own dialog which has blue radio button (green on lollipop) and I need to change it to orange. I managed to get the dialog and change the headline and the divider color using the following:

listPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog dialog = (AlertDialog) listPreference.getDialog();
            if (dialog != null) {
                changeDialog(getApplicationContext(), dialog);
            }
            return true;
        }}); 



public void changeDialog(Context context, final AlertDialog dialog) {
        int titleViewId = dialog.getContext().getResources().getIdentifier("android:id/alertTitle", null, null);
        TextView title = (TextView) dialog.findViewById(titleViewId);
        title.setTextColor(context.getResources().getColor(R.color.orange));
    }

So if the title id is "android:id/alertTitle" and the divder id is "android:id/titleDivider", what is the id for the radio button?

user_s
  • 1,058
  • 2
  • 12
  • 35
  • did you figure out how to do this? – AndroidEnthusiast Mar 07 '16 at 12:24
  • Kind of.. I found a tutorial back then but it was too complicated to implement (you need to add pictures of the radio button and change the image on click or something of this sort) it isn't simple as changing the divider like I did above so I just kept its color. I can try to look it up again if you need it. – user_s Mar 07 '16 at 13:13
  • If you can add it here that will be great, for me and whoever finds this problem in the future. – AndroidEnthusiast Mar 07 '16 at 15:33
  • I couldn't find that link but I found something similar on stack overflow - http://stackoverflow.com/questions/10460715/how-to-customize-list-preference-radio-button BTW - while searching for it I saw that since API 21 you can use buttonTint attribute, so it might be more simple to implement : http://stackoverflow.com/questions/17120199/change-circle-color-of-radio-button-android – user_s Mar 08 '16 at 20:58

1 Answers1

1

The right way to do this is to use <item name="colorAccent">YOUR COLOR</item> in a theme

Arcyno
  • 4,153
  • 3
  • 34
  • 52