Вопрос

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.

Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top