Using Firemonkey, I created a list with TListView
. I want to change the background color of the item when I click on it, AND the color has to be retained even if I click on another item in the list.
Example: If the user clicks Item AAA, its color is changed to green. After that, if the user clicks on another item in the list, Item BBB for example, this second item's color will also turn green, with the first item retaining it's green color.
I've tried this code, which gives no error, but also does not change the color.
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;
How do I change the background color of selected items?
EDIT: Change Alternating Colors in Firemonkey TListView is not a duplicate of this question, because it is about changing the default alternating color whilst here I want to change an individual item's color independently of other items.