1

I want to implement list view like facebook comments that able to load previous comments on top. Here screenshoot of facebook comments.

enter image description here

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?

ikhsanudinhakim
  • 1,554
  • 16
  • 23

1 Answers1

0

There is the Swipe to refresh layout you might want to use for this. Note however that there is no button but an spinner image that is dismissed automatically.

EDIT: Just realized that this does not answer the question. You might want to check out this post that is a possible duplicate.

Community
  • 1
  • 1
GPuschka
  • 522
  • 3
  • 9