Folks,
I've studied this code for a while, and I can't seem to understand why I keep getting a Null Point Error when I try to add an ImageView to the ScrollView.
In debug mode, it appears that all objects are properly assigned.
Anyone have a clue?
I've studied this code for a while, and I can't seem to understand why I keep getting a Null Point Error when I try to add an ImageView to the ScrollView.
In debug mode, it appears that all objects are properly assigned.
Anyone have a clue?
B4X:
Sub LoadImages
Bitmaps.Initialize
Dim files As List
Dim imagesFolder As String
imagesFolder = File.DirRootExternal & "/MySO/photos"
If File.Exists(imagesFolder, "") = False Then
ToastMessageShow("Images folder not found: " & CRLF & imagesFolder, True)
Return
End If
files = File.ListFiles(imagesFolder) 'get all files in this folder
ScrollView1.Initialize(200dip*files.size)
ScrollView1.Panel.Height = 200dip * files.Size 'Set the inner panel height according to the number of images.
Log("# files:" & files.Size)
For i = 0 To files.Size - 1
DoEvents 'required for the ProgressDialog animation
Dim f As String
Dim newView As ImageView
f = files.Get(i)
If f.ToLowerCase.EndsWith(".jpg") Then
Dim b As Bitmap
b.InitializeSample(imagesFolder, f, 200dip, 200dip) 'load the jpeg file and subsample it if it is too large.
newView.Initialize("newView")
newView.Bitmap = b
newView.Gravity = Gravity.FILL
newView.Tag = f
Log("Bitmap:"& newView.Bitmap)
ScrollView1.Panel.AddView(newView, 5dip, 5dip + i * 200dip, ScrollView1.Width - 10dip, 190dip)
ScrollView1.Height = 100%y - 10dip
End If
Next
ToastMessageShow("Found " & Bitmaps.Size & " images", True)
End Sub