FMX.CustomPicker Sample
This sample demonstrates how to use the TComboBox component to customize and invoke an item picker.
Contents
Location
You can find the CustomPicker sample project at:
- Start | Programs | Embarcadero RAD Studio Athens | Samples and then navigate to:
Object Pascal\Mobile Snippets\CustomPicker
CPP\Mobile Snippets\CustomPicker
- 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 CustomPicker sample demonstrates how to use an item picker on Android and iOS devices. The sample uses TComboBox to customize the options of the picker and to allow the user to pick an item and display the text of the selected item on a label.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: CustomPicker.dproj.
- C++: CustomPicker.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Click or tap the TComboBox control. See how it displays the native picker that allows you to select an item.
- Select an item.
- The sample displays the text of the selected item on a label.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
CustomPicker.dproj |
CustomPicker.cbproj |
The project itself. |
uMain.fmx |
uMain.fmx |
The main form where the components are located. |
uMain.pas |
CustomPickerPCH.h, CustomPicker.cpp |
Used to define and implement the sample. |
Information.txt |
Information.txt |
Further information about the sample. |
Classes
TCustomPickerForm is the main form that represents the main window of the sample. It contains the following components:
- A TListBox object containing two TListBoxItems.
- The first TListBoxItem contains a TComboBox object with four TListBoxItems:
- TListBoxItem1 called Item One.
- TListBoxItem2 called Item Two.
- TListBoxItem3 called Item Three.
- TListBoxItem4 called Item Four.
- The second TListBoxItem is empty.
- The first TListBoxItem contains a TComboBox object with four TListBoxItems:
- A ToolBar object with a TLabel object.
Implementation
- The sample uses TComboBox to display a list of items and select an item from it.
- The sample uses TListBox to locate the TComboBox on the first TListBoxItem and to display the selected item on the second TListBoxItem.
When you run the application, there are two TListBoxItems. In the first TListBoxItem, click on the TComboBox next to Pick an Item. Then, the sample displays an item picker that allows you to select one of the four items. When you select an item, an OnChange event displays the text of this item in the second TListBoxItem.
Uses
See Also
- Combo Boxes
- Mobile Tutorial: Using Combo Box Components to Pick Items from a List (iOS and Android)
- FMX.ListBox.TComboBox