Super, vielen Dank. Nur leider zeichnet er unter Windows das Image nicht links sondern addiert was dazu. Der ursprüngliche Test wird leider nicht entfernt (AItem.Text := ''). Und unter Android wird garnichts gezeichnet:
Code:
Function TfrmMain.GetBitmap(Name: String; var Target: TBitmap): Boolean;
var
Size: TSize;
Item: TCustomBitmapItem;
begin
If imgList.BitmapItemByName(Lowercase(Name), Item, Size) then begin
Target.Assign(Item.Bitmap);
Result := true;
end else Result := false;
end;
...
var
TextLabel: TListItemText;
Image: TListItemImage;
MyBitmap: TBitmap;
const
c_ItemDrawable_Image = 'ItemImage';
c_ItemDrawable_TextHeader = 'ItemText';
c_EventImage_Heigth = 25;
c_EventImage_Width = 100;
begin
MyBitmap := TBitmap.Create;
If GetBitmap(AItem.Text, MyBitmap) then begin
Image := AItem.View.FindDrawable(c_ItemDrawable_Image) as TListItemImage;
if (Image=nil)then begin
Image := TListItemImage.Create(AItem);
Image.Name := c_ItemDrawable_Image;
Image.Align := TListItemAlign.Leading;
Image.VertAlign := TListItemAlign.Leading;
Image.Height := c_EventImage_Heigth;
Image.Width := MyBitmap.Width;
Image.PlaceOffset.X := 30;
Image.PlaceOffset.Y := 10;
If not Assigned(Image.Bitmap) then Image.Bitmap := TBitmap.Create;
Image.OwnsBitmap := false;
Image.Bitmap.Assign(MyBitmap);
end;
AItem.Text := '';
AItem.Invalidate;
Exit;
end;
TextLabel := AItem.Objects.FindDrawable(c_ItemDrawable_TextHeader) as TListItemText;
if TextLabel = nil then begin
TextLabel:= TListItemText.Create(AItem);
TextLabel.Name:= c_ItemDrawable_TextHeader;
TextLabel.Align:= TListItemAlign.Leading;
TextLabel.VertAlign:= TListItemAlign.Leading;
TextLabel.TextAlign:= TTextAlign.Leading;
TextLabel.PlaceOffset.X:= 40;
TextLabel.PlaceOffset.Y:= 4;
TextLabel.Font.Size:= 23;
TextLabel.Font.Style := [TFontStyle.fsBold];
TextLabel.Width:= 600;
TextLabel.Height:= 30;
TextLabel.WordWrap := false;
TextLabel.Text:= AItem.Text;
AItem.Text := '';
AItem.Invalidate;
end;