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.

Location

You can find the PullToRefresh sample project at:

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

  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.

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:

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

Samples

Personal tools
Assistance