gridview 点击item变色

 来自博客  https://blog.csdn.net/ChinaGuangZhou000000/article/details/6697184



gridView.setOnItemClickListener(new Gallery.OnItemClickListener(){
   @Override
   public void onItemClick(AdapterView<?> parent, View arg1, int position,long arg3) {
   portal_menu_gridView2.getAnimation();
   for(int i=0;i<parent.getCount();i++){
               View v=parent.getChildAt(i);
               if (position == i) {//当前选中的Item改变背景颜色
                arg1.setBackgroundResource(R.drawable.bottombg_h);
               } else {
                  v.setBackgroundResource(R.drawable.portal_navigation_1bottom);
               }
           }
   }});


猜你喜欢

转载自blog.csdn.net/uglyant/article/details/80487281
今日推荐