Delphi XE5 Android:如何使每个listview项目都有自己的模板? [英] Delphi XE5 Android : how to make each listview item have its own template?

查看:615
本文介绍了Delphi XE5 Android:如何使每个listview项目都有自己的模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让Delphi的TListView在android中表现得像实际的ListView?
,例如列表的每个项目都有自己的视图,在该视图中可以是多个其他视图(组件),如多个文本框和复选框,...?

Is there a way to make the TListView of Delphi to behave like actual ListView in android? for example each item of the list has its own "View" and in that view can be multiple other views(components) like multiple text boxes and check boxes and ...?

推荐答案

是的,有一种方法。我用这两种方法来做。 CreateItem方法是您在列表中放置所需组件的位置。

Yes there is a way. I make it by using these two methods. The CreateItem method is where you put the components you want in the listitem.

procedure TForm1.CreateItem;
var
edit1:TClearingEdit;
editCalendar1:TCustomCalendarEdit;
begin
  edit1:= TClearingEdit.Create(Self);
  edit1.Parent := fItem;
  edit1.Align := TAlignLayout.alClient;
  edit1.Text := 'Blabla';
  edit1.OnChange := actEdit1OnChange;

  editCalendar1 := TCalendarEdit.Create(Self);
  editCalendar1.Parent := fItem;
  editCalendar1.Align := TAlignLayout.alRight;
  editCalendar1.Width := 90;
  editCalendar1.Date := Date;
  editCalendar1.OnChange := actEditCalOnChange;
end;

procedure TForm1.CreateListItem;
begin
  fItem:= TListBoxItem.Create(your_listbox);
  fItem.Parent := your_listbox; //Here you put the ListBox as a parent
  fItem.Align := TAlignLayout.alTop;
  fItem.Text := '';
  fItem.Height := 50;

  CreateItem;
end;

要添加自定义项目到列表中,只需调用CreateListItem方法!在这之前,我使用OnChange方法来接收这里的数据是一个例子:

To add a custom item to the list just call the CreateListItem method! Next to this I use the OnChange method to receive data here is an example:

procedure TForm1.actEditCalOnChange(Sender: TObject);
begin
  label1.text := TCalendarEdit(Sender).Text;
end;

procedure TForm1.actEdit1OnChange(Sender: TObject);
begin
  label2.text := TClearingEdit(Sender).Text;
end;

这篇关于Delphi XE5 Android:如何使每个listview项目都有自己的模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆