Android Question Individual Items from a List

Declan

Well-Known Member
Licensed User
Longtime User
I am retrieving files from a folder and placing the items in a list:
B4X:
    Dim fileList As List
    Dim fileCount As Int
    fileList = File.ListFiles(File.DirRootExternal &  "/Pictures/")
    fileCount = fileList.Size
    Log("File List = " & fileList)
    Log("File Count = " & fileCount)
The Log is:
B4X:
File List = (ArrayList) [IMG_20160901_134832.jpg, IMG_20160901_135028.jpg]
File Count = 2
How do I:
Extract the File Name as a String.
Extract the Image.

Once I have the individual components, I can load into a ListView (ULV)
 

eurojam

Well-Known Member
Licensed User
Longtime User
I am not sure, that I understand your question, but you can loop trough the list like:
B4X:
For Each f As String In fileList
     Log(f)
Next
 
Upvote 0

Yayou49

Active Member
Licensed User
Hi,

You can use something like this:

B4X:
    Dim FileList As List
    FileList = File.ListFiles(File.DirInternal)

    Dim ListImage As List
    ListImage.Initialize

    For i = 0 To FileList.Size-1

        Dim FileName As String = FileList.Get(i)
        If FileName.Contains(".jpg") Then
            Dim img As Bitmap = LoadBitmap(File.DirInternal,FileName)
            ListImage.Add(img)
        End If
 
    Next

After that, with a listview, you can do something like:

B4X:
For i = 0 to ListImage.size - 1
      LstView.AddTwoLinesAndBitmap("Text","Text",ListImage.get(i))
Next
 
Last edited:
Upvote 0
Top