I ran into the same issue. The method call is not seen by the
compiler. Use an object of the class "Context" to make that method
call.
If you are continuing the HelloGallery Example, there is a Context
object already being used called mContext.
So my code looks like this:
public ImageAdapter2(Context c)
{
mContext = c;
TypedArray a = mContext.obtainStyledAttributes
(R.styleable.default_gallery);
mGalleryItemBackground = a.getResourceId
(R.styleable.default_gallery_android_galleryItemBackground, 0);
a.recycle();
}
After this change the example worked fine.
Hope this helps,
HIFI_LEO
On Jun 3, 7:16 am, yaiza <[email protected]> wrote:
> Thank, lilbyrdie. It helped me a lot :)
>
> The thing is I'm still getting an error in function
> obtainStyledAttributes, where the compiler says that
> obtainStyledAttributes(int[]) is undefined.
> I have that class extending BaseAdapter. What am I missing? Should I
> be implementing an Interface or something?
>
> Thanks!
> Yaiza.
>
> On 13 mayo, 20:27, lilbyrdie <[email protected]> wrote:
>
>
>
> > I've answered my own question. Net result is the same, just a
> > different way of getting to the default theme resources, but it's what
> > I was missing.
>
> > Within your attrs.xml file, place a block that looks like the
> > following:
>
> > <declare-styleable name="default_gallery">
> > <attr name="android:galleryItemBackground" />
> > </declare-styleable>
>
> > This basically provides access to the galleryItemBackground in the
> > same way as before, but explicitly making it a styleable now.
>
> > This is now used as before:
>
> > Within the ImageUriAdapter(), load the background:
> > TypedArray a =
> > obtainStyledAttributes(R.styleable.default_gallery);
> > mGalleryItemBackground = a.getResourceId(
> >
> > R.styleable.default_gallery_android_galleryItemBackground, 0);
> > a.recycle();
>
> > Then, within the getView(), apply the background:
>
> >
> > imageView.setBackgroundResource(mGalleryItemBackground);
>
> > I hope this helps someone.
>
> > On May 12, 12:43 pm, lilbyrdie <[email protected]> wrote:
>
> > > Hello,
>
> > > I'm trying to find the "correct" new way to do imageGalleryitems,
> > > previously (as also documented
> > > here:http://developer.android.com/guide/tutorials/views/hello-gallery.html
> > > and
> > > herehttp://developer.android.com/reference/android/widget/Gallery.html)
> > > the correct way was to apply
> > > android.R.styleable.Theme_galleryItemBackground.
>
> > > Of course, this has been removed (see
> > > here:http://groups.google.com/group/android-developers/browse_thread/threa...)
> > > even though theGalleryassumes it will be used (see aboveGallery
> > > documentation).
>
> > > The net effect is that, without this, agallerywith images looks
> > > pretty bad. I could copy out all of the values and resources to
> > > recreate the default look, or use reflection to get at styleable, but
> > > none of that seems like a particularly workable solution.
>
> > > Thoughts? What am I missing?- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---