Recent

Author Topic: LAMW jListView OnDrawItemWidgetBitmap does not seem to work  (Read 285 times)

Robert Gilland

  • Full Member
  • ***
  • Posts: 146
LAMW jListView OnDrawItemWidgetBitmap does not seem to work
« on: April 19, 2019, 03:06:11 am »
HI,

Just attempting to create a listview with a different image per list item, to the left of the text.
The Below code does not seem to work at all, no idea why:


procedure TAndroidModule1.jListView1DrawItemWidgetBitmap(Sender: TObject;
  itemIndex: integer; widgetText: string; out bimap: JObject);
begin
  if( itemIndex >= 0 )and( itemindex < jImageList1.Count )then
    begin
      bimap := jImageList1.GetBitmap(itemIndex);
    end;
end; 

    object jListView1: jListView
      Tag = 1
      Left = 0
      Top = 0
      Width = 292
      Height = 657
      MarginLeft = 0
      MarginTop = 0
      MarginRight = 0
      MarginBottom = 0
      Enabled = True
      Visible = True
      Id = 3721116
      PosRelativeToAnchor = []
      PosRelativeToParent = [rpTop, rpCenterHorizontal]
      LayoutParamWidth = lpMatchParent
      LayoutParamHeight = lpMatchParent
      Items.Strings = (
        'BARRY'
        'FRED'
        'HARRY'
        'MARY'
      )
      BackgroundColor = colbrDefault
      FontColor = colbrMidnightBlue
      FontSize = 0
      WidgetItem = wgNone
      Delimiter = '|'
      TextDecorated = txtNormal
      ItemLayout = layWidgetTextImage
      TextSizeDecorated = sdNone
      TextAlign = alLeft
      HighLightSelectedItemColor = colbrRed
      FontSizeUnit = unitDefault
      ItemPaddingTop = 40
      ItemPaddingBottom = 40
      WidgetTextColor = colbrDefault
      OnDrawItemWidgetBitmap = jListView1DrawItemWidgetBitmap
    end 

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: LAMW jListView OnDrawItemWidgetBitmap does not seem to work
« Reply #1 on: April 19, 2019, 03:11:54 am »


just this:

Code: Pascal  [Select]
  1. procedure TAndroidModule1.jListView1DrawItemWidgetBitmap(Sender: TObject;
  2.   itemIndex: integer; widgetText: string; out bimap: JObject);
  3. begin
  4.       bimap := jImageList1.GetBitmap(itemIndex);
  5. end;  
  6.  
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Robert Gilland

  • Full Member
  • ***
  • Posts: 146
Re: LAMW jListView OnDrawItemWidgetBitmap does not seem to work
« Reply #2 on: April 19, 2019, 03:32:03 am »
Working now, thank you, changed to:
Code: Pascal  [Select]
  1. procedure TAndroidModule1.jListView1DrawItemBitmap(Sender: TObject;
  2.   itemIndex: integer; itemCaption: string; out bimap: JObject);
  3. begin
  4.   bimap := jImageList1.GetBitmap(itemIndex);
  5. end;  
  6.  
  7. object jListView1: jListView
  8.     Left = 0
  9.     Top = 0
  10.     Width = 300
  11.     Height = 662
  12.     MarginLeft = 0
  13.     MarginTop = 0
  14.     MarginRight = 0
  15.     MarginBottom = 0
  16.     Enabled = True
  17.     Visible = True
  18.     Id = 1
  19.     PosRelativeToAnchor = []
  20.     PosRelativeToParent = []
  21.     LayoutParamWidth = lpMatchParent
  22.     LayoutParamHeight = lpMatchParent
  23.     Items.Strings = (
  24.       'BARRY'
  25.       'FRED'
  26.       'MARY'
  27.       'MISSUS'
  28.     )
  29.     BackgroundColor = colbrDefault
  30.     FontColor = colbrDefault
  31.     FontSize = 0
  32.     WidgetItem = wgNone
  33.     Delimiter = '|'
  34.     TextDecorated = txtNormal
  35.     ItemLayout = layImageTextWidget
  36.     TextSizeDecorated = sdNone
  37.     TextAlign = alLeft
  38.     HighLightSelectedItemColor = colbrDefault
  39.     FontSizeUnit = unitDefault
  40.     ItemPaddingTop = 40
  41.     ItemPaddingBottom = 40
  42.     WidgetTextColor = colbrDefault
  43.     OnDrawItemBitmap = jListView1DrawItemBitmap
  44.   end
  45.   object jImageList1: jImageList
  46.     Images.Strings = (
  47.       'btn1_1.png'
  48.       'btn1_2.png'
  49.       'image01.png'
  50.       'image02.png'
  51.       'lazarus_logo.png'
  52.     )
  53.     left = 64
  54.     top = 314
  55.   end                                      
  56.  
  57.