How to listen to the last element of ListView?
There are 10 elements allowed. How to catch that moment when the 10th element is on the screen?
Or when the listview has reached the end?
How to listen to the last element of ListView?
There are 10 elements allowed. How to catch that moment when the 10th element is on the screen?
Or when the listview has reached the end?
ListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView absListView, int firstVisible, int visibleCount, int totalItem) { if(firstVisible + visibleCount == totalItem){ //то что нужно тебе } } });
If you need to do data loading in a listView, for example, 10 elements Boolean isLoad = false
, then you can do this: create Boolean isLoad = false
, and add if((firstVisible + visibleCount == totalCount) && (isLoad) && (totalCount>0))
to the condition , if the condition is met, you вызываешь метод для получения следующих 10 элементов списка (либо как тебе удобно) и делаешь isLoad = false;
, and after adding the following elements you do isLoad = true
Source: https://ru.stackoverflow.com/questions/561422/
All Articles