Simply you can remove an item inside getview method as in the example
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_row, null, false);
viewHolder = new ViewHolder();
viewHolder.img = (ImageView) convertView.findViewById(R.id.img);
convertView.setTag(viewHolder);
} else {
// we call the view created before to not create a view in each time
viewHolder = (ViewHolder) convertView.getTag();
}
final int imgId = imageId.get(position);
viewHolder.img.setImageResource(imgId);
viewHolder.img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, "Clicked " + imgId, Toast.LENGTH_SHORT)
.show();
}
});
// Create a generic swipe-to-dismiss touch listener.
viewHolder.img.setOnTouchListener(new SwipeDismissTouchListener(
viewHolder.img, null,
new SwipeDismissTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(Object token) {
return true;
}
@Override
public void onDismiss(View view, Object token) {
Log.d(TAG, "Image ıd" + imgId);
imageId.remove(position);
remove(position);
notifyDataSetChanged();
}
}));
return convertView;
}