문제

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