Remove items recyclerview code example
Example 1: delete one item from list recycleview
holder.delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openHelper.deleteProduct(shoppingCart.getId());
shoppingCartList.remove(position);
notifyItemRemoved(position);
}
});
Example 2: remove item from adapter android recyclerview
private void removeItem(int position) {
int newPosition = holder.getAdapterPosition();
model.remove(newPosition);
notifyItemRemoved(newPosition);
notifyItemRangeChanged(newPosition, model.size());
}