Android Question Use SMM to Display Photos from Assets Folder on an xCLV

Mahares

Expert
Licensed User
Longtime User
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.
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
 

Attachments

  • xClvviaSMMscreenshot112721.png
    xClvviaSMMscreenshot112721.png
    103.7 KB · Views: 212

Mahares

Expert
Licensed User
Longtime User
I usually do not like to spoil a good answer by posting after it, but on behalf of all forum members I wish you and all the Jewish members a happy Hanukkah.
By the way, how is SMM able to display a bitmap file when there are no ImageView or B4XImageView in the layout. Is that done internally. You mention in the lib write-up: Images are loaded asynchronously using BitmapsAsync
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top