RecyclerView blinking after notifyDatasetChanged()

前端 未结 18 1713
悲&欢浪女
悲&欢浪女 2020-12-07 16:20

I have a RecyclerView which loads some data from API, includes an image url and some data, and I use networkImageView to lazy load image.

@Override
public vo         


        
18条回答
  •  北海茫月
    2020-12-07 16:42

    Using appropriate recyclerview methods to update views will solve this issue

    First, make changes in the list

    mList.add(item);
    or mList.addAll(itemList);
    or mList.remove(index);
    

    Then notify using

    notifyItemInserted(addedItemIndex);
    or
    notifyItemRemoved(removedItemIndex);
    or
    notifyItemRangeChanged(fromIndex, newUpdatedItemCount);
    

    Hope this will help!!

提交回复
热议问题