Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello, I am a beginner in android studio. In a project, after getting images and text from database, they will show in a recyclerview.
In the project:
minSdkVersion 15
       targetSdkVersion 23


First 5 items will show and then after checking that the recyclerview scroll has reached the bottom, other items will download.
//This method would check that the recyclerview scroll has reached the bottom or not
    private boolean isLastItemDisplaying(RecyclerView recyclerView) {
        if (recyclerView.getAdapter().getItemCount() != 0) {
            int lastVisibleItemPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition();
            if (lastVisibleItemPosition != RecyclerView.NO_POSITION && lastVisibleItemPosition == recyclerView.getAdapter().getItemCount() - 1)
                return true;
        }
        return false;
    }



    @Override
    public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
        //Ifscrolled at last then
        if (isLastItemDisplaying(recyclerView)) {
            //Calling the method getdata again
            getData();
        }
    }


But
public class Last_pics extends Fragment implements RecyclerView.OnScrollChangeListener{

needs min sdk 23.
How can I implement it without changing minimum sdk version?
Is there other ways?
Thanks

What I have tried:

implementing
RecyclerView.OnScrollChangeListener
for downloading sections of data from database? Is there other ways to doing it?
Posted
Comments
Nick_3141592654 14-Apr-17 7:38am    
RecyclerView has an onScrolled event that was added at 22.1.0. It's worth checking out.

As a last resort the docs are always worth reading :) https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html
suraty 14-Apr-17 12:11pm    
Is there any other method for doing it? for SDK 15?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900