Android Question Array of Bitmaps is not working

Martin Domian

Member
Licensed User
Longtime User
I wanted to create an array of images because they'll be needed in a later loading routine and will be loaded using an index corresponding to the number in the array.

But it keeps crashing when INIT the bitmap.
BM(i).Initialize(File.DirAssets, Filename)

If I use Dim BM1 as ... BM2 as ... it works, but that's nonsense.
Does anyone know what's wrong here?

Code: Copy
    Dim BM(1 To 11) As Bitmap
    Dim Filename As String
    For i = 1 To 11     
        Filename = "CL" & NumberFormat(i, 2, 0) & ".png"
        If File.Exists(File.DirAssets, Filename) Then
          BM(i).Initialize(File.DirAssets, Filename)
        Else
            Log ("Mist")
        End If       
    Next


Error:
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
 
@stevel05
But it should be
B4X: Copy
Dim BM(11) As Bitmap
If not it will count 0 to 9.
 
Upvote 0
Back
Top