Color Listview Delphi Line Android

Posted on

Question :

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
   listview.linha?.? := clRed;


Answer :

Add a TListView component.

In our example we get the ListView in the FormCreate event:

  i, j : Integer;
  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));

In event OnCustomDrawItem of component TListView :

  if Odd(item.index) then
    Listview1.Canvas.Brush.Color := clred//Todas as linhas √ćmpares
    ListView1.Canvas.Brush.Color := clWhite;//Todas as linhas pares

Now just use your imagination and start adding the Conditions!


Leave a Reply

Your email address will not be published. Required fields are marked *