In Delphi 10 with Firemonkey, at runtime I need that when I click on a list item in a TListView, the background color of this item is changed and it stays anyway so I click on another item. Then, even if you click on another item, the background color of this will also change and will remain that way.
I've already been told to use TStyleBook and change the style of ListView items, but I could not mount the code to run in runtime.
I imagined something like this, but it did not work:
procedure TForm1.lvListasItemClickEx(const Sender: TObject; ItemIndex: Integer;
const LocalClickPos: TPointF; const ItemObject: TListItemDrawable);
var Obj: TFmxObject;
begin
Obj := ListView1.FindStyleResource('itembackground');
if Obj <> nil then
begin
TColorObject(Obj).Color := TAlphaColorRec.Blue;
end;
end;
This code gives no error, but does not work. Also I need to perform the color change only on the clicked item.