Question

After Android 3.0 we can add icon to preference using preference.setIcon(icon). how can i add icons to preference to support older versions than Android 3.0? thank you.

Was it helpful?

Solution

Since Preference.setIcon was only added in API 11, to add icons to preference in older Android versions you could clone the IconPreferenceScreen and then import to you project. You will need to make a few changes to load custom attributes.

After that you can just use the new IconPreferenceScreen in place of a Preference, and add an icon.

IconPreferenceScreen source code

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top