Android Question xCustomListView images

Polaris

Member
Licensed User
Hi there,
I'm new to B4X , only been learning it month or so. So sorry if I'm asking a newbie question,

The problem is this :
I have loaded the xCustomListView class into my project since that is the updated version of CustomListView, recommended for new projects.
I downloaded Erel's code from the forum (( https://www.b4x.com/android/forum/attachments/xcustomlistview-zip.63203/ )) and modified it
somewhat.

Now what I'm trying to do is load some images into the ImageView ( which I added from the designer) as shown in the CustomListView video tutorial. But I can't quite grasp how to structure line 37 , so it adds the images also:

clv2.Add(CreateListItem($"Item #${i}"$, clv2.AsView.Width, 60dip), $"Item #${i}"$)
Next

Also need to add images to the Sub CreateListItem as is missing any reference to images list for now.

I know i could just cut all the existing code out and copy in the code from the Video tutorial, but by posting the question maybe I can learn something new.


Thank you
 

Attachments

  • Proj.1.zip
    16.8 KB · Views: 266

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't see any ImageView in cellitem layout file.

Assuming that you add an ImageView named ImageView1 then you will be able to set an image with:
B4X:
Sub Globals
   
   Private clv2 As CustomListView
   Private Label1 As B4XView
   Private CheckBox1 As B4XView
   Private ImageView1 As B4XView
End Sub

Sub CreateListItem(Text As String, Width As Int, Height As Int, bmp As B4XBitmap) As Panel
   Dim p As Panel
   p.Initialize("")
   p.SetLayout(0, 0, Width, Height)
   p.LoadLayout("CellItem")
   Text = "Eni Spa"
   Label1.Text = Text
   ImageView1.SetBitmap(bmp)
   Return p
End Sub

You can use LoadBitmap or better LoadBitmapResize to load bitmaps.
 
Upvote 0
Top