FMX.Mobile.ListViewRatingsAppearance Sample (Object Pascal)
This is a project that shows how to customize the appearance of a TListView to show a rating as an image. That is, show a different image based on a numeric value of each list view item. It does this by using list view item appearances previously defined in a custom package.
You can find the ListViewRatingsAppearance Sample project at:
- Start | Programs | Appmethod | Samples and then navigate to Object Pascal\Samples\User Interface\ListView
- Subversion Repository: http://sourceforge.net/p/Appmethod/code/HEAD/tree/branches/Appmethod_113/Object%20Pascal/Samples/User%20Interface/ListView
When you run the application, it shows a list view. Each list item shows tree different detail fields under their main label.
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
- Navigate to the location given above and use Ctrl + click to select and open both SampleListViewRatingsAppearancePackage.dpk and SampleListViewRatingsAppearanceProject.dproj at once.
- On the Project Manager, right click your package entry and select Install.
- Double click your project entry on the Project Manager and press F9 or choose Run > Run.
The package defines three subclasses of TPresetItemObjects that implement a custom appearance for list view items. It actually defines a base subclass that is later inherited and extended by the other two subclasses.
These subclasses use instances of a custom class,
TRatingsImageObjectAppearance. Its subclasses TImageObjectAppearance to implement a rating image, a control that shows a different image based on a numeric value. The rest of the fields are inherited from TPresetItemObjects and customized as necessary.
The application uses these subclasses in the ItemAppearance.ItemAppearance and ItemAppearance.ItemEditAppearance properties of the list view to use the appearance defined in the installed package. You can tap ToggleEditMode to see how the application keeps the appearance in edit mode.
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. You must use Fill in Code to actually see a different rating on each list view item; the LiveBindings items do not provide a rating and the default value is used instead.
- FMX.Mobile.ListViewMultiDetailAppearance Sample (Object Pascal)
- FMX.Mobile.ListViewAddThumbAndCaption Sample (Object Pascal)
- FMX.Mobile.ListViewCustomBottomDetail Sample (Object Pascal)