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;
}
}
我使用 ArrayList 作为 GridView 数据。但是当我向下滚动和向上滚动时,我的照片是混合的。混合意味着照片的位置发生了变化。这是为什么?请帮帮我ㅠㅜ