Android Swipe to Refresh edit

Endless Scrolling in Recycleview.

Here I have shared a code snippet for implementing endless scrolling in recycle view.

Step 1: First make a one abstract method in Recycleview adapter like below.

public abstract class ViewAllCategoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    public abstract void load();
}

Step 2:

Now override [onBindViewHolder][1] and `getItemCount()` method of ViewAllCategoryAdapter class and call `Load()` method like below.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
    if ((position >= getItemCount() - 1)) {
        load();
    }
}

@Override
public int getItemCount() {
    return YOURLIST.size();
}

Step 3: Now every backend logic is complete now it’s time to execute this logic.It’s simple you can override load method where you create object of your adapter.this method is automatically call while user reach at end of the listing.

adapter = new ViewAllCategoryAdapter(CONTEXT, YOURLIST) {
      @Override
      public void load() {

          /* do your stuff here */
          /* This method is automatically call while user reach at end of your list. */
      }
  };
  recycleCategory.setAdapter(adapter);

Now load() method automatically call while user scroll at end of list.

Best Luck


Table Of Contents
39 ACRA
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
136 Swipe to Refresh
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close