Android add/replace Items within RecyclerView

前端 未结 2 595
庸人自扰
庸人自扰 2021-01-20 18:20

I know there are lots of threads already on this topic, but none of the given solutions worked for me so far. I\'m trying to add or update an item of a RecyclerView

2条回答
  •  执笔经年
    2021-01-20 18:55

    Use

     mItems.set(position, newItem);
    

    instead of

     mItems.add(position, newItem);
    

    because .set method will replace your data to particular position.

提交回复
热议问题