Android: why is CardView not updating with new user input?

后端 未结 2 1436
旧巷少年郎
旧巷少年郎 2020-12-22 08:14

I have a RecyclerView that creates CardViews from user input (via two EditTexts).

I am able to create the new Cards properly. The first

2条回答
  •  执念已碎
    2020-12-22 08:48

    Looking at your code I see a problem with implementation of addItem method here:

    mItems.add(new ContactItem(contact));
    notifyItemInserted(0);
    

    It seems you are adding item on bottom and notify insertion on top. You should keep insertion and notification aligned in terms of position. In particular, if you want to insert on top you should change your code as follows:

    mItems.add(0, new ContactItem(contact));
    notifyItemInserted(0);
    

提交回复
热议问题