FMX.PullToRefresh Sample
This sample uses the TListView component to create a list of items and demostrates how to handle a OnPullRefresh event.
Contents
Location
You can find the PullToRefresh sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | 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.
Description
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
- Navigate to one of the locations given above and open:
- Delphi: PullToRefresh.dproj.
- C++: PullToRefreshExample.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- 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.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
PullToRefresh.dproj |
PullToRefreshExample.cbproj |
The project itself. |
Unit1.fmx |
Unit1.fmx |
The main form where the components are located. |
Unit1.pas |
PullToRefreshExamplePCH.h, PullToRefreshExample.cpp |
Used to define and implement the sample. |
RandomTextUtils.pas |
RandomTextUtils.h |
Contains different random arrays of strings. |
Classes
TForm1 is the main form that represents the main window of the sample. It contains the following components:
- A TListView object.
Implementation
- 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
.
Uses
See Also
- Customizing FireMonkey ListView Appearance
- Mobile Tutorial: Using LiveBindings to Populate a ListView
- ListView Items Editor