Swipe Down To Refresh ListView With Delphi XE5 Firemonkey On Android And IOS

Delphi XE5 Firemonkey Pull RefreshEmbarcadero has some sample code up which shows you how to do a pull or swipe down to refresh a TListView. A lot of mobile apps like Facebook use this functionality instead of having a refresh button. It saves screen real estate by not having an extra button to deal with. The idea is that you are at the top of the list and you put your finger down on the list and swipe or pull down. The list drags down and then you show a activity spinner above the list. Once the update is complete and the list gets updated the activity spinner goes away. The blog post talks about being for IOS but this will work on both Android and IOS. The code is simple enough and just checks the ScrollViewPos property of TListView. Take a look:

You could combine this code with the TListView RSS viewer demo.

Check out the full blog post and example from Embarcadero.

Update: Download Delphi XE5 Firemonkey Pull To Refresh Demo for Android

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

10 Responses to Swipe Down To Refresh ListView With Delphi XE5 Firemonkey On Android And IOS

  1. Mitsoloth says:

    This really works on iOS but it doesn’t work on Android :/ . You can’t drag the listview off the screen the way you can with iOS. Are there any modifications one should do first?

    • Admin says:

      Well that is a bummer. It should still be possible on Android you would just have to implement the drag part yourself. I don’t have any code handy right now but you could put the TListview inside of a vertical scroll box and then in mouse move or the gesture section if the TListview scroll position is at 0 start adding to the TListview Y until it’s greater than 40 and then continue with the rest of the code.

      Technically you could also look at how it is done in the source code of the TListview for IOS and then bring that code over to the Android version.

      • bssat says:

        wtf? When RefreshPos is not 0?

        • Admin says:

          Hey I didn’t say the code was going to make sense πŸ˜›

          RefreshPos isn’t needed. Looks like I was probably going to use it and then ended up with the PullToRefreshCheck boolean instead.

  2. tefsoft says:

    Excuse me, ListView on how to realize the data load

  3. Lucas says:

    How to paginate TListView with FireDac?

  4. Lucas says:

    I’m trying to use TListView with records on demand, like paginate. How can I implement that with FireDac?

    • Admin says:

      I think it would be possible with TFDLocalSQL. Have your normal query with all of the results and then connect TFDLocalSQL to those results and do your LIMIT page based where against the real results. Then display those 10-20 items in the TListView. You’ll have to come up with a way to navigate between pages though. Either some kind of scroll trigger or just page next and back buttons.


      • Lucas says:

        With a custom FDQuery is possible to paginate. My doubts are on TListView. I think the better way to request a new records demand is on user push up the listview and the listview is showing the last record. So, how to get the last showing record on listview?

        *Note: If you execute at design time a query in TFDQuery, you will see the grid being paginated with a large resultset…

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Blazing Fast XML Component For Delphi XE5 Firemonkey On Android And IOS

There is a new XML parsing component called OXml now available in beta from Ondrej Pokorny which looks to be...