[android-developers] Re: Select image resource dynamically
You can also use something like:
int rid = getResources().getIdentifier("fr", "drawable", getPackageName
());
not the most efficient way but definitely something you can use.
On Dec 19, 6:16 pm, croco <zeug...@gmail.com> wrote:
> Hello Sergiu,
>
> I keep your hint in mind,
>
> for now i've generated the mapping class. Maybe not the best way but
> it is sync with what i have in folder.
>
> Regards.
>
> Croco
> On Dec 19, 2:42 pm, Sergiu Dogaru <creative.art....@gmail.com> wrote:
>
>
>
> > you could try using Reflection, but that might be too complicated for
> > what you need.
> > What I would do is to place all of the images in the assets folder,
> > where you can retrieve them by name.
> > I think it's something like
>
> > Bitmap bmp = BitmapFactory.decodeStream(getResources().getAssets
> > ().openFile("fr.png"));
>
> > On Dec 19, 3:17 pm, croco <zeug...@gmail.com> wrote:
>
> > > Hi all,
>
> > > I'm facing a problem,
>
> > > I've added a folder of 350 images representing country flags in my
> > > project
>
> > > according the device country given by locale. Let's say fr for France
>
> > > I would like set an image with fr.png which is in the res/drawable
> > > folder. How to achieve this without maintaining an ugly map in the
> > > code saying fr = R.drawable.fr etc etc .
>
> > > Thank you for your help.
>
> > > Croco
--
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