using notifyItemRemoved or notifyDataSetChanged with RecyclerView in Android

后端 未结 8 2273
忘掉有多难
忘掉有多难 2020-12-04 17:28

I am creating a list of cards to display using the RecyclerView, where each card has a button to remove that card from the list.

When i use notifyItemRemoved

8条回答
  •  不知归路
    2020-12-04 18:07

    Tried

    public void removeItem(int position) {
        this.taskLists.remove(position);
        notifyItemRemoved(position);
        notifyItemRangeChanged(position, getItemCount() - position);
    }
    

    and working like a charm.

提交回复
热议问题