Thanks for your quick reply. Sounds like a good way for both of your solutions. Yes, I just tried to find a temporary solution: int rid = 0x7f020000 + input; Not sure if it is transplantable?
在2009-10-07,"Balwinder Kaur (T-Mobile USA)" <[email protected]> 写道: > >int rid = getResources().getIdentifier("pic_" + input, "drawable", >"your_package_name"); >Drawable d = getResources().getDrawable(rid); > >You may check out the file MBellishClipartSelector.java from >http://codecamp.pbworks.com/EmbellishYourPictures-BuildanApplicationforanAndroidPhone-2009 > >Balwinder Kaur >Mobile.Software.Development >·T· · ·Mobile· stick together > >The views, opinions and statements in this email are those of the >author solely in their individual capacity, and do not necessarily >represent those of T-Mobile USA, Inc. > > >On Oct 7, 4:14?am, I82Much <[email protected]> wrote: >> 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 -~----------~----~----~----~------~----~------~--~---

