How do I use obtainStyledAttributes(int []) with internal Themes of Android

后端 未结 4 669
说谎
说谎 2020-12-24 09:09

So I have looked around and found out that android.R.styleable is no longer part of the SDK even though it is still documented here.

That wouldn\'t real

4条回答
  •  情书的邮戳
    2020-12-24 09:27

    In the example, they left out the reference to the Context 'c':

    public ImageAdapter(Context c) {
        TypedArray a = c.obtainStyledAttributes(R.styleable.GalleryPrototype);
        mGalleryItemBackground = a.getResourceId(
                R.styleable.GalleryPrototype_android_galleryItemBackground, 0);
        a.recycle();
        return mGalleryItemBackground;
    }
    

    Changing obtainStyledAttributes to c.obtainStyledAttributes should work

提交回复
热议问题