Strange characters in Listview

  

I have this code for an Android project for autoheight the Listview Text. Everything works fine with fix height. When I activate this code LText.Height := ListView1.getItemTextHeight(LText)+10; the autoheight works fine but came with that strange characters on Bold and some times a "Duplicates not allowed" error message.
In Windows works fine but on Android I have this.
for i := 0 to FDMemTable1.RecordCount -1 do
begin
UName := (FDMemTable1.FieldByName(‘username’).Value);
Descr := (FDMemTable1.FieldByName(‘descr’).Value);
Ext := (FDMemTable1.FieldByName(‘ext’).Value);
Url := (FDMemTable1.FieldByName(‘vurl’).Value);
FCanUpdate := False;
LItem := ListView1.Items.Add;
LItem.Data[‘UName’] := UName;
LItem.Data[‘Descr’] := Descr;
LItem.Data[‘Ext’] := Ext;
LItem.Data[‘Url’] := Url;
FCanUpdate := True;
LItem.Adapter.ResetView(LItem);
FDMemTable1.Next;
end;
ListView1.EndUpdate;
end;

procedure TForm7.ListView1UpdatingObjects(const Sender: TObject;
const AItem: TListViewItem; var AHandled: Boolean);
var
h: integer;
LText: TListItemText;
begin
h := 2;
LText := AItem.Objects.FindObjectT<TListItemText>(‘UName_text’);
if LText = nil then
begin
LText := TListItemText.Create(AItem);
LText.Name := ‘UName_text’;
LText.PlaceOffset.X := 18;
LText.PlaceOffset.Y := h;
LText.TextColor := TAlphaColorRec.Black;
LText.TextAlign := TTextAlign.Leading;
LText.TextVertAlign := TTextAlign.Leading;
LText.Font.Size := 14;
LText.Font.Style := [TFontStyle.fsBold];
end;
LText.Width := (Sender as TListView).Width – 18;
LText.Text := AItem.Data[‘UName’].AsString;
LText.Height := 22;
h := Round(h + LText.Height +7);

if AItem.Data[‘Descr’].AsString <> ” then
begin
LText := AItem.Objects.FindObjectT<TListItemText>(‘Descr_text’);
if LText = nil then
begin
LText := TListItemText.Create(AItem);
LText.Name := ‘Descr_text’;
LText.PlaceOffset.X := 18;
LText.PlaceOffset.Y := h;
LText.TextColor := TAlphaColorRec.Black;
LText.TextAlign := TTextAlign.Leading;
LText.TextVertAlign := TTextAlign.Leading;
LText.WordWrap := True;
LText.Font.Size := 13;
LText.Font.Style := [];
end;
LText.Width := (Sender as TListView).Width – 20;
LText.Text := AItem.Data[‘Descr’].AsString;

// LText.Height := ListView1.getItemTextHeight(LText)+10;

LText.Height := 30;

h := Round(h + LText.Height + 5);
end;
AItem.Height := h;
AHandled := True;
end;

The screenshot from my phone.

What goes wrong with this ???

Comments are closed.