I display the image and text in a gridview. That is, each item has an image and a text. it works fine. But I want to know how to determine the range of each gridview item separately in Android.
1) Create an attrs.xml under Race & gt; Value folder
2) Add a resource:.
& lt; Declared-styleable name = "gallery1" & gt; & Lt; Attr name = "android: galleryItemBackground" /> & Lt; / Declared - Styleable & gt; 3) Add the following code to your work:
TypedArray A = getStyledAttributes (R.styleable.Gallery1); Integer mGalleryItemBackground = a.getResourceId (R.styleable.Gallery1_android_galleryItemBackground, 0); A.recycle (); 4) Then set the mGalleryItemBackground as the background of your view, you will get a limit outside your view, for example: imageView.setBackgroundResource (mGalleryItemBackground);
Comments
Post a Comment