5

I am trying to call getIcon on a Preference declared in xml for android. I am calling it in the onCreate for the preference Activity after all the resources have been inflated.

The icon shows up but if I do findPreference(key) then it calls getIcon and on that preference the icon returned is null.

Am I missing something?

eLRuLL
  • 18,488
  • 9
  • 73
  • 99
user1786822
  • 107
  • 1
  • 6
  • 1
    Preference doesn't resolve icons set from XML until it's bound for the first time. You could extend `Preference`, manually load the icon from the `AttributeSet` supplied to the constructor, and pass that to `setIcon(int)`. Or you could postpone the `getIcon()` call until the preference has been displayed on screen. – alanv Sep 24 '15 at 17:21

0 Answers0