Logic fails me
If I have a custom list view showing 4 images per row and say 87 images how would I calculate the number of rows and add the images without breaking code.
I'm sure its obvious but I can't figure it out. I either end up one row short or a row with only one image but crash because im trying to add four images.
here is what I was trying
If I have a custom list view showing 4 images per row and say 87 images how would I calculate the number of rows and add the images without breaking code.
I'm sure its obvious but I can't figure it out. I either end up one row short or a row with only one image but crash because im trying to add four images.
here is what I was trying
B4X:
Dim makesSize As Int
makesSize = Round2((makeList.Size / 4),0)
For i = 0 To (makeList.Size - 1) Step 4
Dim id1 As ImageData = CreateItem2(makeList.GetKeyAt(i))
Dim id2 As ImageData = CreateItem2(makeList.GetKeyAt(i+1))
Dim id3 As ImageData = CreateItem2(makeList.GetKeyAt(i+2))
Dim id4 As ImageData = CreateItem2(makeList.GetKeyAt(i+3))
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, zCLV_Vehicle.AsView.Width, 140dip)
zCLV_Vehicle.Add(p, Array As ImageData(id1, id2, id3, id4))
Next