Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android RecyclerView setOnScrollChangeListener need api 23?

I am using volley - CardView and RecyclerView to create a project this project give information from the json url and show in my application

But the RecyclerView.setOnScrollChangeListener just need api 23 and that will not run in other versions

What should I do?

My dependencies:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile files('libs/volley.jar') }
like image 832
K1-Aria Avatar asked Jan 01 '16 21:01

K1-Aria


1 Answers

You can use addOnScrollListener it works perfectly fine

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);

            //onScrollStateChanged will be fire every time you scroll
            //Perform your operation here

            }
        }
    });
like image 180
Sanjeev Avatar answered Oct 17 '22 09:10

Sanjeev