Wednesday, August 25, 2010

Re: [android-developers] Some confusion on resource IDs

The reflection approach is wrapped up in
getResources().getIdentifier(). Be sure to cache your results, as this
is not fast.

On Wed, Aug 25, 2010 at 4:42 AM, Kostya Vasilyev <kmansoft@gmail.com> wrote:
> 25.08.2010 12:38, Lidia G пишет:
>
> I want to create somehow "R.drawable.flag" by appending the country
> extension "de" .
>
> String countryFlag="flag_"+mySource.countryExtension ;     //something like
> flag_DE
> countryFlag=countryFlag.toLowerCase();                              //
> =flag_de
> flag.setBackgroundResource(R.drawable.countryFlag);       // of course, it's
> not working
>
> Some ways to do it:
>
> 1 - Set up some kind of data structure with string country names and numeric
> resource ids. Use it for looking up resource ids by county name.
>
> 2 - Use Java reflection to get values from the R class.
>
> -- Kostya
>
> --
> Kostya Vasilev -- WiFi Manager + pretty widget --
> http://kmansoft.wordpress.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

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

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate