Good day
I am trying to build an application which requires me to display multiple images in groups with selectable sizes. The images consist of a bitmap and a text field. My idea is to put the image groups in a TListview (Which I hope can display horizontally) and then add these listview groups into a TFlowlayout to manage the screen layout.
However, I simply do not get it right to create a TListview item programmatically to display the image. I have tried to create a TListItemImage as well as simply adding a TListViewItem but neither worked in that I could see anything on the screen.
I am including my test code (Note it pulls images from a folder for testing). The commented out sections will probably indicate some of the experiments that I tried.
I will probably also struggle to add the TListviews to the TFlowlayout. Some advice will be much appreciated. The idea is that the application will run on both Android mobile as well as desktops.
function TForm1.BuildGrpObj(GroupSize, CurrPicIdx: integer): boolean;
var
aPicObj : TListViewitem;
k: Integer;
aPicObjImg: TListItemImage;
// aPicObjImg: TListViewItem;
FName: string;
begin
for k := 0 to GroupSize-1 do
begin
aPicObj := Listview1.Items.Add;
aPicObj.Text := 'Picture: ' + inttostr(CurrPicIdx + k);
aPicObjImg := TListItemImage.Create(aPicObj);
// aPicObjImg := Listview1.Items.Add;
FName := LList[CurrPicIdx + k];
// aPicObjImg.Bitmap := TBitmap.Create;
aPicObjImg.Bitmap.LoadFromFile(FName);
aPicObjImg.Align := TListItemAlign.Center;
aPicObjImg.VertAlign := TListItemAlign.Center;
aPicObjImg.PlaceOffset.X := 0;
aPicObjImg.PlaceOffset.Y := 0;
aPicObjImg.Width := 40;
aPicObjImg.Height := 40;
aPicObjImg.invalidate;
end;
result := true;
end;