Yor*_*iev 1 delphi firemonkey delphi-xe6
我正在尝试将项目分组到TListView对象中,但是我找不到负责对对象进行分组的类,我也无法在文档中找到这样的内容.
该平台是Firemonkey(Android/iOS)/ Delphi XE6
我相信你所指的属性是TListGroups一个收藏TListGroup物品的集合.Delphi文档中提供了一个演示.
不幸的是,它仅在VCL而不是FMX中可用,因为底层功能是TListView包装的Windows ListView控件的一部分.
你在FMX中最接近的是使用TListBox和a TListBoxGroupHeader,它在多设备教程中使用ListBox组件在docwiki中显示表视图(iOS和Android):
procedure TForm1.FormCreate(Sender: TObject);
var
c: Char;
i: Integer;
Buffer: String;
ListBoxItem : TListBoxItem;
ListBoxGroupHeader : TListBoxGroupHeader;
begin
ListBox1.BeginUpdate;
for c := 'a' to 'z' do
begin
// Add header ('A' to 'Z') to the List
ListBoxGroupHeader := TListBoxGroupHeader.Create(ListBox1);
ListBoxGroupHeader.Text := UpperCase(c);
ListBox1.AddObject(ListBoxGroupHeader);
// Add items ('a', 'aa', 'aaa', 'b', 'bb', 'bbb', 'c', ...) to the list
for i := 1 to 3 do
begin
// StringOfChar returns a string with a specified number of repeating characters.
Buffer := StringOfChar(c, i);
// Simply add item
// ListBox1.Items.Add(Buffer);
// or, you can add items by creating an instance of TListBoxItem by yourself
ListBoxItem := TListBoxItem.Create(ListBox1);
ListBoxItem.Text := Buffer;
// (aNone=0, aMore=1, aDetail=2, aCheckmark=3)
ListBoxItem.ItemData.Accessory := TListBoxItemData.TAccessory(i);
ListBox1.AddObject(ListBoxItem);
end;
end;
ListBox1.EndUpdate;
end;
Run Code Online (Sandbox Code Playgroud)
这产生(图像来自指定的docwiki)
