FMX.PullToRefresh Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample uses the TListView component to create a list of items and demostrates how to handle a OnPullRefresh event.


You can find the PullToRefresh sample project at:

  • Start | Programs | Embarcadero RAD Studio Athens | Samples and then navigate to:
    • Object Pascal\Multi-Device Samples\User Interface\PullToRefresh
    • CPP\Multi-Device Samples\User Interface\PullToRefreshExample
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.


The PullToRefresh sample demonstrates how to handle a OnPullRefresh event for a list of items on Android and iOS applications. This sample uses TListView to create a list of items and writes an OnPullRefresh event to specify what happens when the user pulls down the list of items.

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: PullToRefresh.dproj.
    • C++: PullToRefreshExample.cbproj.
  2. Select the target platform, iOS and Android supported.
  3. Press F9 or choose Run > Run.
  4. Interact with the sample:
    • See the list of 20 items.
    • Pull down the list of items.
      • A new item appears at the top of the list.
      • The last item disappears from the list.


File in Delphi File in C++ Contains



The project itself.



The main form where the components are located.


PullToRefreshExamplePCH.h, PullToRefreshExample.cpp

Used to define and implement the sample.



Contains different random arrays of strings.


TForm1 is the main form that represents the main window of the sample. It contains the following components:


  • The sample uses TListView to displays a collection of items in a list.

When you run the application, the sample creates a list of 20 random items using the Add method of TAppearanceListViewItems. The items are composed of three string fields: ComonNames, CommonSurnames and SampleTopics. Each one of the three fields that form each item is chosen randomly from an array of 20 strings. Moreover, when you pull down the list of items, the sample handles the OnPullRefresh event of the TListView object. The OnPullRefresh event uses the Insert and Delete methods of TAppearanceListViewItems to insert a new random item and to delete an existing item, respectively. The Insert method, inserts the new item at the first position of the list and shifts the other items, while the Delete method deletes the last item of the list.

Note: To successfully call the OnPullRefresh method, you have to set the PullToRefresh property to True.


See Also