1

I just started programming in Basic4android. I have created 2 layouts. splash and search. I want to display the splash layout for about 2 seconds and then automatically move to the search layout. This is the code I have so far.

Sub Process_Globals

    Dim SplashTimer As Timer 

End Sub

Sub Activity_Create(FirstTime As Boolean)

    SplashTimer.Initialize("SplashTimer", 3000)
    SplashTimer.Enabled = True

    If FirstTime = True Then
        Activity.LoadLayout("splash")
    End If

End Sub

Sub SplashTimer_Tick
    Activity.LoadLayout("search")
End Sub

The problem is even though it moves to the search layout after 3 seconds, the splash layout is still visible in the background also. Can anyone please tell me how to correct this issue?

Isuru
  • 30,617
  • 60
  • 187
  • 303

1 Answers1

2

You should load the splash layout into a Panel (with Panel.LoadLayout) and add the Panel to the activity.

Call Panel.RemoveView to remove the panel with its layout.

Erel
  • 1,802
  • 2
  • 15
  • 58
  • Thanks for the reply Erel. From the designer, I've put a panel and added other Views to it. When I run it, it shows an error. Please take a look at [this screenshot](http://i.imgur.com/Ro0AG.png). It shows the code I have so far and the error message I'm getting. What am I missing here? Thanks in advance. :) – Isuru Jun 19 '12 at 20:36
  • 1
    I guess that your layout file also include a panel named Panel1. Note that it is better to ask questions in the forum. – Erel Jun 20 '12 at 06:38
  • I'm sorry I don't own B4A yet so I don't have access to the forums, I just stumbled upon B4A on a PC at my uni. I'll be buying it as soon as I collect enough money :) Anyway you were right. I removed the Panel from the designer and added it from code. It throws this error. [Here](http://pastebin.com/MgdRv4TN) is my code. What am I doing wrong? and just to see if it works, I tried it [this](http://pastebin.com/aD0tdMgm) way too. Setting the `Visible` and `Enabled` properties to False. It works but I'm not convinced if it is the right way to do this. Can you please rectify it? Thank you. – Isuru Jun 20 '12 at 07:52