Search code examples
androiddelphifiremonkeytlistviewdelphi-10.2-tokyo

TListView change color from existing item android platform


I need some example how to change color text item for each row from my list view in FireMonkey.

I try something like this but unsuccessfully.

 for i := 0 to lvArtikli.ItemCount-1 do
        begin

          AItem := lvArtikli.Items.AppearanceItem[i];

          pk := AItem.Data['txtPK'].AsString;

          if pk = '' then
          begin
             //change color
            TListItemText(AItem.Objects.FindDrawable('txtPK')).TextColor := TAlphaColorRec.Red;

          end;

  end;

Solution

  • In order to color a certain column, and for each row it is necessary to put the following code on event onUpdateObjects.

    procedure TfrmMeni.lvKorektivnoUpdateObjects(const Sender: TObject;const AItem: TListViewItem);
    begin
    
    TListItemText(AItem.Objects.FindDrawable('txtPK') as TListItemText).TextColor:= TAlphaColorRec.Gold;
    
    end;