Have this code in Process_Globals:
Dim MenuItems As Int: MenuItems = 5
Dim MenuImages( ) As String
Dim MenuButtons() As BitmapData
MenuImages = Array As String( "f1.png", "f2.png", "f3.png", "f4.png", "f5.png" )
Then in Activity_Create i try to read all images in a following way:
For i = 0 To MenuItems - 1
MenuButtons( i ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( i ) )
Next
Compiler reports no error, but application on my phone display the following Error dialog:
an error has occured in sub:main_activity_create (B4A Line: XXX )
MenuButtons(i).Bitmap=LoadBitmap( File.DirAssets, MenuImages(i))
java.lang.ArrayIndexOutOfBoundsException
Continue - Yes/No
When I try with explicit value, that is 100% inside array boundaries:
Dim I As Int: I = 1
MenuButtons( I ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( I ) )
I got this error message:
Programm paused at line XXX:
MenuButtons( I ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( I ) )
and same for this:
MenuButtons( 2 ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( 2 ) )
So, what i'm doing wrong ? All files are at place
Also I notice i'm unable ( got an error msg ) to setup array elements ia a following way:
MenuImages(0) ="f1.png".
Whats wrong here ? Just typical for all Basics languages )
Thank you
Dim MenuItems As Int: MenuItems = 5
Dim MenuImages( ) As String
Dim MenuButtons() As BitmapData
MenuImages = Array As String( "f1.png", "f2.png", "f3.png", "f4.png", "f5.png" )
Then in Activity_Create i try to read all images in a following way:
For i = 0 To MenuItems - 1
MenuButtons( i ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( i ) )
Next
Compiler reports no error, but application on my phone display the following Error dialog:
an error has occured in sub:main_activity_create (B4A Line: XXX )
MenuButtons(i).Bitmap=LoadBitmap( File.DirAssets, MenuImages(i))
java.lang.ArrayIndexOutOfBoundsException
Continue - Yes/No
When I try with explicit value, that is 100% inside array boundaries:
Dim I As Int: I = 1
MenuButtons( I ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( I ) )
I got this error message:
Programm paused at line XXX:
MenuButtons( I ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( I ) )
and same for this:
MenuButtons( 2 ).Bitmap = LoadBitmap( File.DirAssets, MenuImages( 2 ) )
So, what i'm doing wrong ? All files are at place
Also I notice i'm unable ( got an error msg ) to setup array elements ia a following way:
MenuImages(0) ="f1.png".
Whats wrong here ? Just typical for all Basics languages )
Thank you