B4J Question ListView and ImageView error/bug

lymey

Active Member
Licensed User
Longtime User
Hi,
when I try to add an ImageView to a ListView it works fine, UNLESS I add
B4X:
iv.PreserveRatio=True
Then the scrolling becomes erratic (cant use the scroller), and the log shows:
Apr 07, 2017 4:42:34 PM com.sun.javafx.scene.control.skin.VirtualFlow addTrailingCells
INFO: index exceeds maxCellCount. Check size calculations for class anywheresoftware.b4j.objects.ListViewWrapper$MyCallBack$1

This is really annoying.
The complete code for this routine is:
B4X:
Dim iv As ImageView
                iv.Initialize("iv_ListItem")
                iv.PreserveRatio=True
                iv.Width=ListView1.Width
                iv.SetImage(fx.LoadImage("C:\Users\"& username &"/Pictures/", s))
                iv.Tag = "C:\Users\"& username &"/Pictures/" & s
                Log("iv_listitem is: " & "C:\Users\"& username &"/Pictures/" & s)
                ListView1.Items.Add(iv)
If it's a bug or unresolvable, is there an efficient way to load the images into the listview and preserve the aspect ratio?
 

lymey

Active Member
Licensed User
Longtime User
It works properly here with PreserveRatio set to True (and the result is much better). It is probably a display driver issue.

You can try to load each image, get its width and size and then load another small copy with the correct width and height using LoadImageSample.
This will also save memory.
Thanks Erel,
I made the change as you suggested and had the same result. So I changed the images to see if that made a difference. It did. but I can't seem to figure out why at the moment. If I discover what the difference is with the images by process of elimination I will post the findings.
 
Upvote 0
Top