Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load more data from database and show in listview android

I want to load data when ScrollView reach at the threshold. First, I want to show last 20 rows from database and show in ListView then after using SwipeRefreshLayout load another 20 rows get from database and show in ListView and so on...

Thank you

like image 869
Ankit Radadiya Avatar asked Mar 26 '26 22:03

Ankit Radadiya


1 Answers

What you are searching for is called EndlessScrollListener. You will have to extend the class EndlessScrollListener and implement the onLoadMore method.

public class MyEndlessScrollListener extends EndlessScrollListener {

   @Override
   public void onLoadMore(int page, int totalItemsCount) {
        loadData(page);  
   }
}

And set the listener on the listView :

listView.setOnScrollListener(new EndlessScrollListener());

You can use the other constructors of the EndlessScrollListener if you want.

like image 59
Dimitri Avatar answered Apr 01 '26 06:04

Dimitri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!