Simple CustomListView question

asiammyself

Member
Licensed User
Longtime User
Hi I'm working with the customlistview library and just tweaking it and seeing what happens. Right now I'm trying to get it to display an image in the list put can't get it working quite right. See the attachment below. Basically what i've done is replaced a couple lines in CreateListItem with these:
B4X:
Dim ImageView1 As ImageView
ImageView1.Initialize("")
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "splash_zone2.jpg")
ImageView1.Height = 20
ImageView1.Width = 20

p.AddView(ImageView1, 280dip, 2dip, 50dip, Height - 4dip) 'view #2

When I run it the program pauses at the line where height is set. I'm a newbie to this and just trying to get my head around working with images. See attachment for full code
 

Attachments

  • CustomListImage.zip
    37.2 KB · Views: 139

Mahares

Expert
Licensed User
Longtime User
1. Remove these 2 lines:
B4X:
ImageView1.Height = 20
ImageView1.Width = 20
because the width and height are given in this line below:
B4X:
p.AddView(ImageView1, 280dip, 2dip, 50dip, Height - 4dip) 'view #2
2. I changed the 1000 to 20 in the below code because 1000 was giving me outofmemory error.
B4X:
For i = 1 To 20
      clv2.Add(CreateListItem("Item #" & i, clv2.AsView.Width, 50dip, "OtherText"), 50dip, "Item #" & i)
Next
You can experiment with other range of i. Your project will then work.
 
Upvote 0
Top