简体   繁体   中英

How to show new item(update or add) in recycleview top in list

How to show new item(update or add) in

recycleview top in list

In update or add method add these 2 lines below:

mArrayList.add(0, item);
notifyItemInserted(0); 

Where "item" is the object of mArrayList.

Use the below code to add a new item at the top of the RecyclerView:

you_array_list.add(0, your_item);
notifyItemInserted(0);
mRecyclerView.smoothScrollToPosition(0);

Hopefully this will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM