Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:MyGridView';她的照片好坏参半_Android_Gridview_Baseadapter - Fatal编程技术网

Android:MyGridView';她的照片好坏参半

Android:MyGridView';她的照片好坏参半,android,gridview,baseadapter,Android,Gridview,Baseadapter,我使用ArrayList作为GridView数据。 但当我向下滚动和向上滚动时,我的照片是混合的。 混合意味着照片的位置改变了。 为什么呢? 请帮帮我ㅠㅜ 试试这个。。。使用视图保持架保存详细信息 public class ImageAdapter extends BaseAdapter { LayoutInflater inflater; ImageView photo; CheckBox CHECK; BitmapFactory.Options options

我使用ArrayList作为GridView数据。 但当我向下滚动和向上滚动时,我的照片是混合的。 混合意味着照片的位置改变了。 为什么呢?
请帮帮我ㅠㅜ

试试这个。。。使用视图保持架保存详细信息

public class ImageAdapter extends BaseAdapter {
    LayoutInflater inflater;
    ImageView photo;
    CheckBox CHECK;
    BitmapFactory.Options options;

    public ImageAdapter(Context c) {
        inflater = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    public int getCount() {
        return receivedphoto.size();
    }
    public Object getItem(int position) {
        return receivedphoto.get(position);
    }
    public long getItemId(int position) {
        return position;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null)  {
            convertView = inflater.inflate(R.layout.phototab_list, parent, false);
            photo = (ImageView)convertView.findViewById(R.id.PHOTOS);
            CHECK = (CheckBox)convertView.findViewById(R.id.PHOTOSCHECK);
            options = new BitmapFactory.Options();
            options.inSampleSize = 16;
        }
        Log.i("LOAD", position + "");
        if(ReceivePhotos.get(position) == null)  {
            ReceivePhotos.set(position, BitmapFactory.decodeFile((String)(receivedphoto.get(position)), options));
        }   
        photo.setImageBitmap(ReceivePhotos.get(position));
        int check = Photoischeck.get(position);
        if(check == 0)  {
            CHECK.setChecked(false);
        } else {
            CHECK.setChecked(true);
        }
        return convertView;
    }
}

谢谢你帮助我!!
public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        final ViewHolder holder;
        if(convertView == null)  {
            view = inflater.inflate(R.layout.phototab_list, parent, false);
            holder = new ViewHolder();
            holder.photo = (ImageView)convertView.findViewById(R.id.PHOTOS);
            holder.CHECK = (CheckBox)convertView.findViewById(R.id.PHOTOSCHECK);
            holder.options = new BitmapFactory.Options();
            holder.options.inSampleSize = 16;
        }else {
     holder = (ViewHolder) view.getTag();
}
        Log.i("LOAD", position + "");
        if(ReceivePhotos.get(position) == null)  {
            ReceivePhotos.set(position, BitmapFactory.decodeFile((String)(receivedphoto.get(position)), options));
        }   
        holder.photo.setImageBitmap(ReceivePhotos.get(position));
        int check = Photoischeck.get(position);
        if(check == 0)  {
            holder.CHECK.setChecked(false);
        } else {
            holder.CHECK.setChecked(true);
        }
        return view;
    }