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.
Asked
Active
Viewed 153 times
1 Answers
1
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.

Filipe Batista
- 1,862
- 2
- 24
- 39
-
thank for the reply. i tried to use IconPreferenceScreen class. i found another question. http://stackoverflow.com/questions/5765186/how-to-add-icons-to-preference. so i tried to work like explain in there. but it just so only empty space. can you give some suggestion to make this work? – Kelum Deshapriya Feb 06 '14 at 03:38
-
check if drawable is not null in the constructor where you retrieve the drawable – Filipe Batista Feb 06 '14 at 09:34
-
it is set. but problem is there is no even title or summary. – Kelum Deshapriya Feb 06 '14 at 16:45
-
could you put your xml preferences file? which api version are you testing? – Filipe Batista Feb 07 '14 at 09:48