1
In Delphi 10 with Firemonkey, at runtime I need that when clicking on a list item of a Tlistview, the background color of this item be changed and remain so even if I click on another item. Then, even if you click on another item, its background color will also be changed and will remain so.
I’ve seen them say to use Tstylebook and change the style of Listview items, but I couldn’t assemble the code to run in Runtime.
I imagined something like this, but it didn’t 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 does not give error, but does not work. Also I need to execute the color change only in the clicked item.