1

How can I add an icon to a preference, the preference references an app so I can get the app's icon. I can get the icon as a drawable from the app, how can I add it to the preference?

        Preference preference = new Preference(this);
        preference.setTitle(app.activityInfo.loadLabel(pm));

EDIT:

I used this, but it says it requires at least api lvl 11, I hope someone comes with a better solution though:

        if(sdk > android.os.Build.VERSION_CODES.HONEYCOMB) {
            preference.setIcon(app.loadIcon(pm));
            }
lisovaccaro
  • 32,502
  • 98
  • 258
  • 410
  • check answer on this [question](http://stackoverflow.com/questions/5765186/how-to-add-icons-to-preference) – Bishan Jan 11 '13 at 03:30

1 Answers1

1

I'm doing this which only works on android post honeycomb, I hope there is a more compatible option:

        if(sdk > android.os.Build.VERSION_CODES.HONEYCOMB) {
            preference.setIcon(app.loadIcon(pm));
            }
lisovaccaro
  • 32,502
  • 98
  • 258
  • 410