You can use Java reflection with your application's R.drawable class to build the list.
-- Kostya Vasilyev -- http://kmansoft.wordpress.com 18.12.2010 8:30 пользователь "darrinps" <[email protected]> написал: > What I am wanting to do is offer the user a list of image names and > allow them to choose one then display that image in another activity. > > > > > On Dec 17, 10:42 pm, darrinps <[email protected]> wrote: >> Thanks. I tried doing that but it seems to be an old API so I tried >> to convert it to what is there today. There must be some mistake I >> have made that keeps this from working. >> >> Note that it didn't like mResources.startPreloading(); The method >> simply was not there, although finishPreloading() is. I commented the >> startPreloading() line out. >> >> Secondly, it didn't like the format of the array when it looked like >> this: >> >> <array name="preloaded_drawables"> >> <item>@drawable/sym_def_app_icon</item> >> >> So, I changed that to this: >> >> <array name="preloaded_drawables"> >> <item type="drawable" name="sym_def_app_icon"></item> >> >> When I execute this line: >> >> TypedArray ar = >> mResources.obtainTypedArray(com.standardandroid.swarooms.R.array.preloaded_drawables); >> >> I get a warning: >> ResourceType Invalid package identifier when getting bag for >> resource number 0x7f050000 >> >> Then an exception: >> Failure preloading resources >> android.content.res.Resources$NotFoundException: Array resource ID >> #0x7f050000 >> at android.content.res.Resources.obtainTypedArray(Resources.java: >> 424) >> >> Any idea what I am doing wrong? >> >> On Dec 13, 1:41 am, Dianne Hackborn <[email protected]> wrote: >> >> > I would recommend just having another resource holding an array of the >> > drawables to include. See for example this declaring one: >> >> >http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;... >> >> > < http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...>And >> > this reading it: >> >> >http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;... >> >> > Sure, it is one more step required when adding a resource, but at runtime it >> > is going to be far more efficient than other solutions that require scanning >> > through resources or R symbols or such. >> >> > On Sun, Dec 12, 2010 at 8:17 PM, darrinps <[email protected]> wrote: >> > > Is there any way for an Android app to read the file names of all the >> > > files stored under drawable (or for that matter any other directory)? >> >> > > I'd like to have it so I can plop in a new file and have the app read >> > > the name for me for use in a dynamically sized list of radio buttons >> > > (one button per file) that lists the name of the file by the radio >> > > button. >> >> > > I've done something like this with contacts, but I am not sure how you >> > > read the file names from something like the drawable directory! >> >> > > Thanks. >> >> > > Darrin >> >> > > -- >> > > 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]<android-developers%[email protected]> <android-developers%[email protected]<android-developers%[email protected]> > >> > > For more options, visit this group at >> > >http://groups.google.com/group/android-developers?hl=en >> >> > -- >> > Dianne Hackborn >> > Android framework engineer >> > [email protected] >> >> > Note: please don't send private questions to me, as I don't have time to >> > provide private support, and so won't reply to such e-mails. 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- 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

