dynamically resolve resource id

Problems with Canvas, OpenGL, etc...

dynamically resolve resource id

Postby oxyde » Fri Oct 08, 2010 11:01 am

Hey,

I have 52 png named 1.png, 2.png, ... Each representing 1 card.
In my game i know that i have to draw card number 37. How can i do that ? BitmapFactory.decodeResource(getResources(), ???)

Maybe i could use a map with keys = 1,2,3,.. and values R.drawable.1, R.drawable.2, ... but is there a clever way ?

thanks
oxyde
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Aug 11, 2010 1:28 pm
Location: paris, france

Top

Re: dynamically resolve resource id

Postby droid7 » Thu Oct 14, 2010 1:17 pm

you can try with:
String id = "1";
R.drawable.class.getField(id);
Visit my website: echlab software
droid7
Freshman
Freshman
 
Posts: 9
Joined: Thu Oct 14, 2010 1:03 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests