FMX.Mobile.ListViewAddThumbAndCaption Sample (C++)

From Appmethod Code Examples
Jump to: navigation, search

This is a project that shows how to customize the appearance of a TListView to show a thumbnail with a caption on the right-hand side of every list view item. It does this by modifying the appearance of the list view at run time.

Location

You can find the ListViewAddThumbAndCaption Sample project at:

Description

When you run the application, it shows a list view. Each list item shows a thumbnail image with a caption on the right-hand side corner.

You can tap the ToggleEditMode button to have the list view enter a selection edit mode where you can select several items. The buttons at the bottom, LiveBindings and Fill in Code, let you fill the list view with items defined using LiveBindings or defined at run time, respectively.

How to Use the Sample

  1. Navigate to the location given above and open SampleListViewAddThumbAndCaptionProject.cbproj.
  2. Press F9 or choose Run > Run.

Implementation

To render the thumbnail and caption on each list view item, the application handles the OnUpdateObjects event of the list view. For each list view instance, the application creates and initializes the required TListItemImage instance that will hold the thumbnail and the TListItemText instance that will hold the caption.

When using LiveBindings, the application handles the OnFilledListItem event of the instance of TLinkFillControlToField to fill list view items with the required data for their new fields: the bitmap of the thumbnail and the text of the caption.

You can change at design time the values of the ItemAppearance.ItemAppearance and ItemAppearance.ItemEditAppearance properties of the list view to see how, at run time, the application extends any selected appearance with a thumbnail and a caption on the right-hand side of each item.

Note: This application is not meant to work with every item appearance, but you can make it work with all of them.

The LiveBindings button uses TLinkFillControlToField to fill the list view using LiveBindings. The Fill in Code button uses a for loop to fill the list view with items created at run time.

Uses

See Also