JoanZapata / android-iconify

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
http://joanzapata.com/android-iconify
Other
3.93k stars 526 forks source link

Access icon's resource ID #65

Closed tng10 closed 9 years ago

tng10 commented 9 years ago

Hey guys

Is there a way to access icon's resource ID like we do using the code bellow?

int icon = R.drawable.ic_action_play;

I just want to put some icons in a navigation drawer. I'm using an adapter (http://goo.gl/RFzABb), so I need to do this with Java and not using XML.

Do you know if is possible to do that?

mikepenz commented 9 years ago

@tng10 not quite sure why you need the ressource id? we got no ressource id of the icon because those are generated during runtime.

I think you should read some more tutorials, this is the wrong place to ask beginners questions.

To give you a hint how to get started. The tutorial has following line:

holder.imgIcon.setImageResource(weather.icon);

Don't set the image by it's ressource. We got a drawable so you can set the image like this:

holder.imgIcon.setImage(weather.icon);

The class of weather.icon will then be Drawable instead of int

Cheers

tng10 commented 9 years ago

Hey @mikepenz !

You're right, I've done like this and it works like a charm!

Thank you very much!

mikepenz commented 9 years ago

@tng10 you are welcome.