matt parker wrote:
> So, in case anyone encounters this issue, it turns out you can do
> this:
> 
> int resourceId = (getResources().getIdentifier(<my image name (no
> extension)>, "drawable", <my package name>));
> 
> and then use the resourceId as normal.  So, you can just put the name
> of the resource into the xml.

Note that calls to getIdentifier() may not be quick, so please cache the
results. That value will not change in the lifespan of your application
instance (unless there's some wacky scenario I'm missing), so tuck it in
a static data member or something once you get it.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to