Hammad Nasir Hammad Nasir - 1 year ago 192
Android Question

How to add newly added data from firebase to the top of the recyclerview and not at the bottom? Please see details

I'm developing an app in which I'm retrieving some data from


The problem is that everytime I save something, it gets retrieved and gets added to the bottom of the

What I want is I want the newly added data to get added to the top of the recyclerview and not at the bottom.

I have no idea how to do what I want to do.

Please let me know.

Answer Source

well first of all the question is about recyclerview and you posted code of your data retrieval. and if your want to add a new item to recycler view use

mArrayList.add(position, item);

for data to be inserted in first row use

mArrayList.add(0, item);

and then you can use mRecyclerView.smoothScrollToPosition(0); to scroll to the top.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download