I suppose you could also do something like

int[] iconRefs = {
    R.drawable.pic_1,
    ...
    R.drawable.pic_n
}

if (input >= 0 && input < n) {
    // Account for 0 based indexing
    return iconRefs[input - 1];
}

This code gets the reference out (I might be wrong in how you
reference it, maybe R.res.drawable, don't have my eclipse handy);
you'd have to use the standard way of actually getting that drawable
image.

On Oct 5, 11:08 pm, wine <[email protected]> wrote:
> hi,
>
> I have met an issue.
> There are some pics in the res/drawable named as pic_1.png, pic_2.png,
> pic_3.png, pic_4.png.... I want to load someone according to the
> input.
> For instance, if I input 2, I want to load pic_2.png. If input 3, will
> load the pic_3.png....
> How to achieve? Need your expert help here...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to