How to change the color of a Delphi / Android listview line?
To have the color changed as some condition is true:
se a = 1 then
listview.linha?.? := clBlue
entao
listview.linha?.? := clRed;
How to change the color of a Delphi / Android listview line?
To have the color changed as some condition is true:
se a = 1 then
listview.linha?.? := clBlue
entao
listview.linha?.? := clRed;
Add a TListView
component.
In our example we get 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 event OnCustomDrawItem
of component TListView
:
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 the Conditions!