FMX.Mobile.ListViewCheckList Sample (C++)
This is a project that shows how to make the display mode of a TListView behave as a check list, where you can tap items to add or remove them from the current selection.
- Note: You can easily implement a check list in edit mode using one of the default TListView.ItemAppearance.ItemEditAppearance values.
You can find the ListViewCheckList Sample project at:
- Start | Programs | Appmethod 1.16 | Samples and then navigate to
CPP\Mobile Samples\User Interface\ListView\ListViewCheckList
- Subversion Repository: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE8//CPP/Mobile%20Samples/User%20Interface/ListView/ListViewCheckList
When you run the application, it shows a list view. Tapping an unselected item shows a checked check mark on its right-hand side. Tapping a selected item hides that check mark.
How to Use the Sample
- Navigate to the location given above and open ListViewCheckListProject.cbproj.
- Press F9 or choose Run > Run.
This application keeps a list of indexes of selected items.
The item appearance of this list view in display mode is the default value,
ListItem, but this appearance has been modified. The properties of the TListView.ItemAppearance.Item.Accessory appearance object have been changed as follows:
To show or hide check marks as you tap list view items, this application handles the OnItemClick event of the list view. The handler of this event shows or hides the Accessory appearance object and updates the list of selected items that the application keeps.
This application also handles the OnUpdateObjects event of the list view, where it:
- Adjusts the width of the Text appearance objects, so that text does not cover the check mark in the selected items.
- Sets the visibility of the Accessory of each list view item based on the list of selected items. This is necessary because the rotation resets the list items to their default appearances.