Thanks
I have found an example here :
http://www.anddev.org/viewtopic.php?p=17846
"For example: I have a file bug.png in the "/res/drawable/", so i get
its ResourceID with the following code:
Java:
int resID = getResources().getIdentifier
("org.anddev.android.testproject:drawable/bug", null, null);
// or
int resID = getResources().getIdentifier("bug", "drawable",
"org.anddev.android.testproject");"
On 4 juin, 20:35, Romain Guy <[email protected]> wrote:
> Look at the Resources class, it has everything you need.
>
>
>
> On Wed, Jun 3, 2009 at 2:12 PM, revo <[email protected]> wrote:
>
> > Hi,
>
> > I have a button and i put a picture in it. I have a list of pictures
> > and i want to know what is the best practice to adapt a integer to a
> > drawable name.
>
> > By example, i have :
> > if (element == 0) {
> > button.setBackgroundResource(R.drawable.picture_0);
> > } else if (element== 1) {
> > button.setBackgroundResource(R.drawable.picture_1);
> > } else if (element == 2) {
> > button.setBackgroundResource(R.drawable.picture_2);
> > } else if (element== 3) {
> > button.setBackgroundResource(R.drawable.picture_3);
> > }
>
> > and i want to get something like :
> > button.setBackgroundResource("R.drawable.picture_" + element);
>
> > Thanks
> > Sylvain MOUQUET
>
> --
> Romain Guy
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support. All such questions should be posted on
> public forums, where I and others can see and answer them
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---