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
-~----------~----~----~----~------~----~------~--~---

Reply via email to