I tried reading pictures from local files in SMM example 2 thus:
B4X:
filenm2b = (List1.Get(x)) 'i should always take note in b4xtable or album.can be used for tag to identify each cell
filenm2b = filenm2b.SubString(filenm2b.LastIndexOf("/") + 1)
pnl.GetView(x).GetView(1).Text = filenm2b
MediaManager.SetMediaFromFile(pnl.GetView(x).GetView(0), xui.DefaultFolder, "myalbum2/"&filenm2b,"image/*", Null) 'l2 is a list of the files
I only get three images from folder being repeated as displayed below instead of displaying eight/nine different pictures available in the folder
as shown in the images below:
The sample code is attached below via Google Drive due to a bit Upload Limit: SMM Example2
I've just went over your code. I see many mistakes.
Don't call ListFiles inside VisibleChanged event. List the files once and store the list.
B4X:
If Success Then
For x = 0 To 2
Dim t As Int = data.IndexOfFirstImage + x
If t >= List1.Size Then
Exit
End If
filenm2b = (List1.Get(x)) 'i should always take note in b4xtable or album.can be used for tag to identify each cell
filenm2b = filenm2b.SubString(filenm2b.LastIndexOf("/") + 1)
pnl.GetView(x).GetView(1).Text = filenm2b
MediaManager.SetMediaFromFile(pnl.GetView(x).GetView(0), xui.DefaultFolder, "myalbum2/"&filenm2b,"image/*", Null) 'l2 is a list of the files
Next
End If
Thank you so much, Erel. There are two File.ListFiles in the code, If i remove File.ListFiles in CustomListView1_VisibleRangeChanged, i get same result as earlier complained, but if i remove that of B4XPage_Created, i get blank page and list1 becomes empty and Files becomes unknown in the code below:
B4X:
Wait For (File.ListFilesAsync(xui.DefaultFolder&"/myalbum2")) Complete (Success As Boolean, Files As List)
If Success Then
For Each f As String In Files
List1.Add(File.Combine(xui.DefaultFolder&"/myalbum2", f))
Next
' 'MsgboxAsync(List1.Get(0), List1.Get(1))
End If
If i remove File.ListFiles, which code will i use to replace it?
I've just went over your code. I see many mistakes.
Don't call ListFiles inside VisibleChanged event. List the files once and store the list.
B4X:
If Success Then
For x = 0 To 2
Dim t As Int = data.IndexOfFirstImage + x
If t >= List1.Size Then
Exit
End If
filenm2b = (List1.Get(x)) 'i should always take note in b4xtable or album.can be used for tag to identify each cell
filenm2b = filenm2b.SubString(filenm2b.LastIndexOf("/") + 1)
pnl.GetView(x).GetView(1).Text = filenm2b
MediaManager.SetMediaFromFile(pnl.GetView(x).GetView(0), xui.DefaultFolder, "myalbum2/"&filenm2b,"image/*", Null) 'l2 is a list of the files
Next
End If
filenm2b = (List1.Get(x)) <----should be t here instead of x.
I've just went over your code. I see many mistakes.
Don't call ListFiles inside VisibleChanged event. List the files once and store the list.
B4X:
If Success Then
For x = 0 To 2
Dim t As Int = data.IndexOfFirstImage + x
If t >= List1.Size Then
Exit
End If
filenm2b = (List1.Get(x)) 'i should always take note in b4xtable or album.can be used for tag to identify each cell
filenm2b = filenm2b.SubString(filenm2b.LastIndexOf("/") + 1)
pnl.GetView(x).GetView(1).Text = filenm2b
MediaManager.SetMediaFromFile(pnl.GetView(x).GetView(0), xui.DefaultFolder, "myalbum2/"&filenm2b,"image/*", Null) 'l2 is a list of the files
Next
End If
filenm2b = (List1.Get(x)) <----should be t here instead of x.
Thank you so much Erel, i wouldn't have been able to identify and solve the problem without your help. One question thread solved out of five question threads . I really thank you