Customize And Sort TListView LiveBindings Data With Firemonkey On Android And IOS


Sarina DuPont from Embarcadero has a new tutorial up which demonstrates how to customize your TListViews when using LiveBindings in Delphi XE5 Firemonkey (and AppMethod specifically). Specifically the blog post talks about how to add headers to your TListViews, how to sort the data, and how to add a prefix to each data item in the TListView. This tutorial applies to Delphi XE6 Firemonkey as well and it should run cross platform on Android, IOS, Windows, and OSX. For adding the headers she bound the property from the data called ColorsName onto both the header and the items (ItemHeader.Text and Item.Text respectively). Then she used the FillHeaderCustomFormat property to customize what appears in the header field and used the following code to just get the first letter: SubString(%s, 0, 1). She also changed a property on ColorsName so that it will not repeat and will not shuffle the data. The trick for sorting data appears to be to change the IndexFieldNames property so that it contains the name of the field that you want to sort alphabetically. Lastly in order to apply a prefix the the data you’ll want to add the following code to the FillDisplayCustomFormat property: “My Prefix ” + UpperCase(%s) which will add the words ‘My Prefix ‘ before each item in the TListView. It looks like it can be kind of tricky to get the LiveBindings data in a TListView set up the way you want but once you learn how it works it could really speed up development.
Head over and check out the full blog post plus screen shots on how to sort and customize TListView LiveBindings data.

Comments are closed.