Y
Y
YarikRock2014-10-21 11:52:19
Android
YarikRock, 2014-10-21 11:52:19

How to understand in RecyclerView on Android that it has reached the end of the list?

How to understand in RecyclerView on Android that it has reached the end of the list? In the ListView I did this:

public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    boolean loadMore = firstVisibleItem + visibleItemCount >= totalItemCount;
    if (loadMore && !getLoaderManager().hasRunningLoaders()) {
        getLoaderManager().restartLoader(LOADER_ID);
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
YarikRock, 2014-10-21
@YarikRock

In the adapter class I wrote the following 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();
    }
}

R
rybakov_aleksey, 2014-10-22
@rybakov_aleksey

Use the LayoutManager there are methods to get the position of the elements on the screen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question