Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The reason for this problem is the resources they tell you to put into res/values/attrs.xml are:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;declare-styleable name="HelloGallery"&gt; &lt;attr name="android:galleryItemBackground" /&gt; &lt;/declare-styleable&gt; &lt;/resources&gt; </code></pre> <p>But then you get this adapter, which Eclipse can't figure out and frankly makes no sense:</p> <pre><code>public ImageAdapter(Context c) { mContext = c; TypedArray a = obtainStyledAttributes(android.R.styleable.Theme); mGalleryItemBackground = a.getResourceId( android.R.styleable.Theme_galleryItemBackground, 0); a.recycle(); } </code></pre> <p>That's because you shouldn't have "android." preceeding the resources, the styleable name is Theme here but HelloGallery in the actual resource, and the galleryItemBackground puts android between the styleable name and the attribute like this: Theme_android_galleryItemBackground</p> <p>So if want the ImageAdapter method to work with the resources you're given, you should rewrite it like this:</p> <pre><code>public ImageAdapter(Context c) { mContext = c; TypedArray a = obtainStyledAttributes(R.styleable.HelloGallery); mGalleryItemBackground = a.getResourceId( R.styleable.HelloGallery_android_galleryItemBackground, 0); a.recycle(); } </code></pre> <p>For future problems regarding resources (R.* cannot be resolved type errors), examine /gen/R.java for what the resources are actually being named.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload