Reputation: 229
I have RecyclerView and I wish to download more data when my list ended. In ListFragment I had this code:
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
boolean loadMore = firstVisibleItem + visibleItemCount >= totalItemCount;
if (loadMore && !getLoaderManager().hasRunningLoaders()) {
getLoaderManager().restartLoader(LOADER_ID);
}
}
What should I use with RecyclerView to get the same result?
Upvotes: 1
Views: 206
Reputation: 229
In Adapter class I wrote this code
@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
Item item = mItems.get(position);
viewHolder.Text.setText(item.getTitle());
if (position == mItems.size() - 1) {
mListener.onListEnded();
}
}
Upvotes: 2