This was just an example that fit the example you provided. I trimmed
down the array to only one .png file which I verified time  and again
was under the drawable directory and reworked the layout of the file
to match the example. The entire arrays.xml file which is found under
the values directory looks like this:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

     <array name="preloaded_drawables">
                <item>@drawable/aggies</item>
        </array>
</resources>

The same thing happens at the same line.

I get a warning first:
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)

The code is IDENTICAL. I copied and pasted it except for the preload
that I had to comment out.




On Dec 18, 1:02 pm, Dianne Hackborn <[email protected]> wrote:
> startPreloading() is not relevant to this; that is for the code there that
> is preloading the drawables it gets from the array.
>
> Is there actually a sym_def_app_icon drawable in your app?  If not...  well
> yeah, that won't work, it doesn't exist.
>
> You should just use the syntax I showed to make an array of references to
> your *own* drawables, which you can retrieve with the same code as shown
> using obtainedTypeArray().
>
> The last XML syntax you have shown is just not right, so it's not surprising
> it doesn't work.
>
>
>
> On Fri, Dec 17, 2010 at 8: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
>
> --
> 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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to