I want to implement list view like facebook comments that able to load previous comments on top. Here screenshoot of facebook comments.
So, on facebook app, when I clicked button "Load previous comments" it append data on the first position of the list without changing listView state/position.
In my project I use RecylcerView with loadmore button on the header. On the header, I put "Load Previous button". When the button is clicked, it put new data into the list.
for (int i = 0; i <= 10; i++) {
list.add(0, "New data on top");
}
After new data appended to list, I tried calling notifyDataSetChanged to make change happen, and call smoothScrollToPosition on my recycler view to make it scrolled into the first position before new data added.
adapter.notifyDataSetChanged();
recyclerView.smoothScrollToPosition(10);
But the problem is it scrolling up. So I wanna make RecylerView stay on the last position before new data added just like facebook comment.
Can anybody suggest me how to implement this?