How does Android change the GridView highlight color?
•
Android
How to change the highlight color of ImageView in GridView
I tried this,
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(width, height));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setBackgroundResource(R.drawable.menu_beh);
// imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
String s=(String)HiveApp.mgd[position].posters[2].image.url;
// imageView.setImageDrawable(getPicture(items[position]));
HiveApp.id.download(s, imageView);
// id.DisplayImage(s, imageView);
return imageView;
}
resolvent:
I solve it myself. You should add it to your layout XML
android:listSelector="@drawable/panel_picture_frame_background"
Not this
imageView.setBackgroundResource(R.color.gridview_highlight_selector);
thank you
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码