How to update/refresh specific item in RecyclerView

前端 未结 13 1368
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 18:31

I\'m trying to refresh specific item in RecyclerView.

Story: Whenever user clicks on item, it shows AlertDialog. User can

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 18:43

    You can use the notifyItemChanged(int position) method from the RecyclerView.Adapter class. From the documentation:

    Notify any registered observers that the item at position has changed. Equivalent to calling notifyItemChanged(position, null);.

    This is an item change event, not a structural change event. It indicates that any reflection of the data at position is out of date and should be updated. The item at position retains the same identity.

    As you already have the position, it should work for you.

提交回复
热议问题