variable drawable resource

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

variable drawable resource

Postby rellik1982 » Mon Mar 30, 2009 12:31 pm

Hello everybody !

For my first post on this very good forum, i'd like to know if is possible to get a resource (drawable) dynamically.

Example of what i want to do :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String var = "image1";
  2.  
  3. getResource().getDrawable(R.drawable.var) // => i would load the image1
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


so for var = "image42", i would load the image42...

But I can't use R.drawable.var, indeed the image var.png does not exist ;)

Is it possible to do such a thing, and how ?

Thanks in advance
rellik1982
Freshman
Freshman
 
Posts: 8
Joined: Mon Mar 30, 2009 12:24 pm

Top

Postby rellik1982 » Thu Jun 04, 2009 12:10 pm

rellik1982
Freshman
Freshman
 
Posts: 8
Joined: Mon Mar 30, 2009 12:24 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests