How it works…
Since we have to intercept when the user has reached the bottom of the list, we have added a ScrollListener. We have overridden the onScroll method, and we are using the canScrollVertically method. The canScrollVertically method was added in API level 14, and it is used to check whether this view can be scrolled vertically in a certain direction. It takes an integer argument (negative to check scrolling up and positive to check scrolling down) and returns a boolean (true if possible, false if not). In our example, we have supplied a positive integer, which will return true if the view can be scrolled down and false if it can't be. If it can't be further scrolled down (meaning that the data is exhausted), we will add data to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access