I have 46 photos from 46 png files located in Assets folder that I want to display on an xClv (preoptimized Clv) via SMM four photos per row. I am using Erel’s example #2 as a basis. But all I get is the first 4 photos displayed on each row as shown on the screenshot. Here is the code in: CustomListView1_VisibleRangeChanged
I am not sure I am applying the MediaManager.SetMediaFromFile correctly. Thank you for any help.
I am not sure I am applying the MediaManager.SetMediaFromFile correctly. Thank you for any help.
B4X:
Sub CustomListView1_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
Dim item As CLVItem = CustomListView1.GetRawListItem(i)
Dim pnl As B4XView = xui.CreatePanel("")
item.Panel.AddView(pnl, 0, 0, item.Panel.Width, item.Panel.Height)
Dim data As MyImageData = item.Value
pnl.LoadLayout("item2")
Dim x As Int
For x = 0 To 3
If data.IndexOfFirstImage + x >= TotalNumberOfImages Then Exit 'VERY IMPORTANT in case # of pictures is not divisible
Dim s As String =l2.Get(x)
s=s.SubString2(0, s.LastIndexOf("."))
pnl.GetView(x).GetView(1).Text = s 'label text
pnl.GetView(x).Tag = data.IndexOfFirstImage + x 'inside the loop
MediaManager.SetMediaFromFile(pnl.GetView(x).GetView(0), File.DirAssets, l2.get(x),"image/png", Null) 'l2 is a list of the files
Next
Next
MediaManager.TrimMediaCache
End Sub