Manage file.dirAssets...

skipsy

Member
Licensed User
Longtime User
Hi all,

I'd like to change the bakground between a couple of pictures.
I have added those file in B4A (files tab).
If I understood correctly, those file are part of the code (!)

So, Iam wondering which one of that code is the best :
Code:
Sub AFFICHE_FOND
   Dim BORDURE As Rect
   Dim random As Int

   random = Rnd( 1, 11 )

   BKGRND.Initialize( File.DirAssets, "backgnd-" & NumberFormat( random,2,0 ) & ".jpg" )
    dBKGRND.Initialize( BKGRND )
   Activity.Background = dBKGRND
end sub
or
Code:
dim BKGRND (11) as BitMap
BKGRND(1).Initialize( File.DirAssets, "backgnd-01.jpg" )
BKGRND(2).Initialize( File.DirAssets, "backgnd-02.jpg" )
BKGRND(3).Initialize( File.DirAssets, "backgnd-03.jpg" )
etc..

Sub AFFICHE_FOND
   Dim BORDURE As Rect
   Dim random As Int

   random = Rnd( 1, 11 )

   dBKGRND.Initialize( BKGRND( random ) )
   Activity.Background = dBKGRND
end sub

???

Thks,
WW
 
My preference was the 1st one too.
Gonna try Margret suggestion... Much more "elegant" than mine.

Thank you.
WW
 
Upvote 0
Back
Top