Android Question Problem in showing Splash Screen before layout

Zvi

Member
Licensed User
Hi, I'm having difficulty in showing a splash screen before showing the layout.
The splash screen shows but then the controls of the layout appear on top of it before the splash transfers to the layout.
As you can see in the attached code, I even tried using a blank layout before the main layout, but the main layout controls still appear on the splash screen.
I tried using CallSubDelayed but I guess I'm not using it correctly.
How can I show the splash screen followed, after an interval, by the main layout?
Grateful for any help...

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim MyFade As SplashFade
    Dim Exitcmnd As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("Start")
    splash
    changelayout
    
End Sub

Sub Activity_Resume
    
End Sub

Sub changelayout
    Activity.LoadLayout("Main_Bidding")
End Sub

Sub splash
    MyFade.Initialize(Activity, Me, "BridgeImagesmall.bmp", Gravity.CENTER, 3000, 200, "Left", False)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Exitcmnd_Click
    ExitApplication
End Sub
 

Zvi

Member
Licensed User
Ah, solved it by using Sleep and starting with a blank layout. If I use the same ms delay in sleep as in MyFade it is synchronised beautifully.
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim MyFade As SplashFade
    Dim Exitcmnd As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("LayoutPlain")
    splash
    Sleep(2000)
    Activity.LoadLayout("Main_Bidding")
End Sub

Sub Activity_Resume
    
End Sub

Sub splash
    MyFade.Initialize(Activity, Me, "Bridgeimagebigger.bmp", Gravity.CENTER, 2000, 200, "Left", False)
End Sub
 

udg

Expert
Licensed User
I'd have done in a different way.
Option1: a timer to keep the splash on for those 2 seconds, then in timer tick event remove all views from Activity and load the real main layout
Option 2: start a splash component (there are few on the forum or you can write your own) that responds to commands start/stop. This way you can show the splash for as long as you need to iniztialize your stuff, then dismiss it and load the real operative layout

just my 2c
 

ac9ts

Active Member
Licensed User
Use 2 panels? Load pnlSplash with the splash layout. Keep pnlMain hidden until it's finished. Set pnlSplash to invisible and pnlMain to visible. This is a simplified explanation but it's something I've done before.
 
Top