Question:
How to change the color of a row in Delphi / Android listview ?
To have the color changed according to any condition to be true:
se a = 1 then
listview.linha?.? := clBlue
entao
listview.linha?.? := clRed;
Answer:
Add a TListView
component.
In our example let's populate the ListView in the FormCreate
event:
var
i, j : Integer;
begin
for i := 1 to 10 do
with Listview1.Items.Add do begin
Caption := 'Item '+ IntToStr(i);
for j := 1 to 3 do
Subitems.Add('SubItem '+IntToStr(i)+IntToStr(j));
end;
In the OnCustomDrawItem
event of the TListView
component:
if Odd(item.index) then
Listview1.Canvas.Brush.Color := clred//Todas as linhas Ímpares
else
ListView1.Canvas.Brush.Color := clWhite;//Todas as linhas pares
Now just use your imagination and start adding Conditions!