Recent

Author Topic: (SOLVED) jListView image question  (Read 542 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2243
    • Lazarus and Free Pascal italian community
(SOLVED) jListView image question
« on: December 16, 2022, 03:29:42 pm »
Hi all, I'm experimenting with the jListView object. And in addition to the text I would like to put an image on each line, I found a way to do this, but it allows me to put the same image on all lines. But I want to change the image based on criteria at runtime. To understand it, it would be enough for me to see that on even lines it puts an image and on odd lines it puts another image.
Can you help me? I enclose a very small project to show where I have arrived.
« Last Edit: December 19, 2022, 11:27:32 am by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

rsu333

  • Full Member
  • ***
  • Posts: 107
Re: jListView image question
« Reply #1 on: December 17, 2022, 02:39:55 pm »
Please refer demo example  ,

xinyiman

  • Hero Member
  • *****
  • Posts: 2243
    • Lazarus and Free Pascal italian community
Re: jListView image question
« Reply #2 on: December 17, 2022, 05:39:27 pm »
What demonstrative example? They are innumerable
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

rsu333

  • Full Member
  • ***
  • Posts: 107
Re: jListView image question
« Reply #3 on: December 18, 2022, 05:20:56 am »
You can  see demo exm at lamw_manager>LAMW>lazandroidmodulewizard>demos>GAI >AppListViewDemo
About 7 demo you can refer which are helpful

xinyiman

  • Hero Member
  • *****
  • Posts: 2243
    • Lazarus and Free Pascal italian community
Re: jListView image question
« Reply #4 on: December 18, 2022, 12:01:41 pm »
but I watched them. I just didn't understand how to set different images for each row of the listview
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2243
    • Lazarus and Free Pascal italian community
Re: jListView image question
« Reply #5 on: December 19, 2022, 11:27:19 am »
Solved with this code

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.ListView1DrawItemBitmap(Sender: TObject;
  2.   itemIndex: integer; itemCaption: string; out bimap: JObject);
  3. begin
  4.      if ((itemIndex mod 2)=0) then
  5.      begin
  6.         bimap := Self.jImageList1.GetBitmap(0)
  7.      end
  8.      else
  9.      begin
  10.           bimap := Self.jImageList1.GetBitmap(1);
  11.      end;
  12. end;  
  13.  
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

rsu333

  • Full Member
  • ***
  • Posts: 107
Re: (SOLVED) jListView image question
« Reply #6 on: December 19, 2022, 02:21:08 pm »
Great !
This will useful to other also

 

TinyPortal © 2005-2018