Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android how to change gridview highlight color?

how can change the highlight color of a imageView inside gridview.

I've 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;
}
like image 712
Vervatovskis Avatar asked Dec 05 '22 17:12

Vervatovskis


1 Answers

I resolve it my self, you shoud add this to your layout xml

 android:listSelector="@drawable/panel_picture_frame_background"

and not this

imageView.setBackgroundResource(R.color.gridview_highlight_selector);

thanks

like image 75
Vervatovskis Avatar answered Dec 23 '22 11:12

Vervatovskis