Android drawables : Is there any way to somehow link the int IDs to the R drawable IDs? -


i have 718 drawables in drawable-mdpi, drawable-hdpiand drawable-xhdpi folders, names 1.png, 2.png... 718.png. (they pokémon sprites)

so, depending on pokémon, want load 1 of them show it. however, cannot use number directly identify r drawable id.

is there way (besides of 718-case switch or hashmap<integer,integer>) somehow link int ids r drawable ids?

you try:

string sprite = "drawable/"+number;  int imageresource = getresources().getidentifier(sprite, null, getpackagename()); 

the drawable folder image in. number number of image want. e.g. 1.png


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -