Hello all those smarter than me.
I want to present my users with a list of images (thumbnails) where they will see all images in a given directory. Select one & return its url to my app.
I found this app by erel but I don't understand how it works and can't get it to display my images.
my images are at https://www.locksdownunder.com/LaraImages/uploads/
I just don't get it or is there a better way?
Yes i've searched but cant really find what i need
Thank You
I want to present my users with a list of images (thumbnails) where they will see all images in a given directory. Select one & return its url to my app.
I found this app by erel but I don't understand how it works and can't get it to display my images.
my images are at https://www.locksdownunder.com/LaraImages/uploads/
I just don't get it or is there a better way?
Yes i've searched but cant really find what i need
Thank You
B4X:
Sub Globals
Private CustomListView1 As CustomListView
Private PCLV As PreoptimizedCLV
Private xui As XUI
Private Label1 As B4XView
Type MyImageData (IndexOfFirstImage As Int)
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
PCLV.Initialize(Me, "PCLV", CustomListView1)
For i = 1 To 600 Step 4
PCLV.AddItem(150dip, xui.Color_White, CreateMyImageData(i))
Next
PCLV.ShowScrollBar = False 'no fast scrolling
PCLV.ExtraItems = 5
PCLV.Commit
End Sub
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
'Create the item layout
pnl.LoadLayout("Item")
For i = 0 To 3
pnl.GetView(0).GetView(i + 4).Text = data.IndexOfFirstImage + i
DownloadAndSetImage($"https://i.picsum.photos/id/${data.IndexOfFirstImage + i}/200/300.jpg"$, pnl.GetView(0).GetView(i))
Next
Next
End Sub
Sub DownloadAndSetImage(Url As String, ImageView As B4XView)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Url)
Wait For (j) JobDone (j As HttpJob)
If j.Success Then
Try
If ImageView.Parent.Parent.IsInitialized Then
Dim bmp As B4XBitmap = j.GetBitmapResize(ImageView.Width, ImageView.Height, True)
ImageView.SetBitmap(bmp)
End If
Catch
Log(LastException)
End Try
End If
j.Release
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Public Sub CreateMyImageData (IndexOfFirstImage As Int) As MyImageData
Dim t1 As MyImageData
t1.Initialize
t1.IndexOfFirstImage = IndexOfFirstImage
Return t1
End Sub
Last edited: