Removing a preference in a PreferenceActivity is pretty simple.

However, if your preference is within a category, you need to get a reference to that category and remove it from there.

The Material Design of Android Lollipop has made it easier for developers to customize the theme of their apps. However, making it compatible for pre-Lollipop devices still has its limitations.

I tried to change the preference title color by using textColorPrimary and it did not work. So I had to do it programmatically.

There are two ways to do this. If you have any custom class that extends Preference, then you can add this code in the onBindView() method.

If you are using the existing Preference class or even the CheckBoxPreference, you can do it this way:

That should do the trick!

While there is now RadioButton Preference widget in Android, you can use the existing CheckBoxPreference widget, add the same OnPreferenceClickListener and add a little code to ensure that only one CheckBox gets clicked.

To start with, here is a sample of a preference XML file.

And in the onCreate() method, you can do it like this:

That should do it.

Related Posts Plugin for WordPress, Blogger...