滚动gridview时,图标会自动更改

时间:2016-09-22 10:20:37

标签: android gridview scrollview

我在网格视图中有一些图标。选择图标后,它将被刻度标记替换。但是当滚动网格视图时,图标处于orinal形式(未更改)。所以请帮我找一个解决方案。!!

在这里输入代码

 public View getView(int position, View convertView, ViewGroup parent) {
 View v;
 View myview=convertView;

  if (myview == null) {

      imageView = new ImageView(mContext);

    }else
  {
      imageView = (ImageView) convertView;

  }

    imageView.setLayoutParams(new GridView.LayoutParams(130, 130));
    //imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    //imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    imageView.setPadding(1, 1, 1, 1);

    //imageView.setImageResource(mThumbIds[position]);
    Log.d("new", "newFrg0");
    try {
        String icon_name_val = null, icon_link_val = null, icon_flag_val = null;
        DatabaseHandler db = new DatabaseHandler(mContext);

        List<HomeIconset> icondetails = db.geticondetails();
        for (HomeIconset sp : icondetails) {
            icon_name_val = sp.getIcon_name();
            icon_link_val = sp.getIcon_link();
            icon_flag_val = sp.getIcon_flag();
            Log.d("new", "newFrg1");

            if (icon_name_val.equals(null)) {
                Log.d("new", "newFrg2");
                imageView.setImageResource(mThumbIds[position]);
            } else {
                Log.d("hhhh", icon_name_val + " " + icon_link_val + " " + icon_flag_val);
                int iconPosition = getPosition(icon_name_val);

                ArrayList<String> listOfSomething1 = new ArrayList<String>();
                listOfSomething1.add(String.valueOf(iconPosition));

                for (int i = 0; i < listOfSomething1.size(); i++) {
                    Log.d("arraylist", listOfSomething1.get(i));
                }

                Log.d("str", String.valueOf(iconPosition) + " " + String.valueOf(position));

                if (listOfSomething1.contains(String.valueOf(position))) {
                    Log.d("contains", String.valueOf(position));
                    compressImage(icon_name_val);
                    //IconSelectionFragment.positionList.add(String.valueOf(position));
                    break;

                } else {
                    imageView.setImageResource(mThumbIds[position]);
                    //IconSelectionFragment.positionList.remove(String.valueOf(position));
                }
            }

        }

    } catch (Exception e) {
        Log.d("excep", e.getMessage().toString());
    }
    return imageView;
}

0 个答案:

没有答案