How to detect when FMX List View is scrolled to the bottom?

  

I’m working on a Firemonkey TListView to display search results. This list loads 25 items at a time, but could potentially show hundreds of items.

I need to detect when the user has scrolled down to the bottom, so that I can fetch the next 25 items to show in the list. However, I cannot find the appropriate properties to determine this.

There’s the OnPullRefresh event, but that applies to scrolling to the top of the list and pulling it down. What I need is similar, but for the bottom of the list instead of the top.

There’s the OnScrollViewChange event, which seems appropriate. There’s also the ScrollViewPos property, which is also useful. However, I cannot figure out what to compare that number to – specifically, the maximum possible value for ScrollViewPos. Something like ScrollViewMax is what I would need.

But I cannot find anything more to accurately detect that user has scrolled to the bottom.

How can I detect when a user has scrolled to the bottom of a Firemonkey TListView so that I can load more search results?

EDIT

If this is not possible for whatever reason, there is an alternative to add a dummy item to the end of the list with a “Load More…” button. But I’d rather it be automated.

EDIT2

I forgot to mention… I have the Search Box showing in this list view, and items can have a variable height. If calculating this based on item contents is the only way, then such a calculation needs to be perfect. I don’t want to know when user is “approaching” or “near” the bottom, but when user exactly hits the bottom of the list.

Comments are closed.