After useful comments in the chat, the removal function was added:
public class ImageAdapter extends BaseAdapter { private Context context; List<ImageUpload> imageUploads; int resource; public ImageAdapter(Context context, List<ImageUpload> imageUploads, int resource) { this.context = context; this.imageUploads = imageUploads; this.resource = resource; } public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View gridView = (View) convertView; if (convertView == null) { gridView = new View(context); if (imageUploads.get(position).getOutputMetadata().getFilename().equals("null")) { gridView = inflater.inflate(R.layout.item_upload_default, null); ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload); imageView.setImageResource(resource); } else { gridView = inflater.inflate(R.layout.item_upload, null); ImageView imageView = (ImageView) gridView.findViewById(R.id.iv_upload); ImageView closeView = (ImageView) gridView.findViewById(R.id.photo_close_btn); final ProgressWheel progress = (ProgressWheel) gridView.findViewById(R.id.loader_photo); ImageUpload mobile = imageUploads.get(position); if (imageUploads.get(position).isLoadImage()) Picasso.with(context) .load(StringUtil.URLADS_THUMBLER_RESIZE + 150 + "x" + 150 + "/" + StringUtil.URLADS_THUMBLER_IMAGE + mobile.getOutputMetadata().getFilename()) .into(imageView, new Callback() { @Override public void onSuccess() { progress.setVisibility(View.GONE); } @Override public void onError() { } }); else { File f = new File(imageUploads.get(position).getPath()); Picasso.with(context) .load(f) .into(imageView); } closeView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { imageUploads.remove(position); } }); } } return gridView; } But there was a new problem, after I click on the delete button, I get an error:
java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1 And points to this line ... imageUploads.remove (position);