Switching to new Activity

rfresh

Well-Known Member
Licensed User
Longtime User
I have a button that I want to press to display a new page. I have the following code to do that:

Activity.LoadLayout("Setup")

I created a setup.bal file in the Designer and did the layout etc.

When I touch the Setup button to display this setup screen, the components display but on top of the existing screen components. I thought the switch over to the new screen would just show those components on that new screen.

Do I have to destroy or kill the current layout first?

Thanks...
 

JonPM

Well-Known Member
Licensed User
Longtime User
To start another activity you need StartActivity(Setup). And in that activity you would have the Activity.LoadLayout(Setup)
 
Upvote 0

admac231

Active Member
Licensed User
Longtime User
When you load a new layout you are essentially just drawing the new views to the activity.

If you want to have separate "screens" you should create a new activity for each layout (this keeps things much cleaner as well in my opinion).

But to answer your question,

B4X:
For i = Activity.NumberOfViews - 1 To 0 Step -1
  Activity.RemoveViewAt(i)
Next

From klaus. Also, that is the 2nd result when searching for "Activity.LoadLayout". The search function is invaluable :)
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
To start another activity you need StartActivity(Setup). And in that activity you would have the Activity.LoadLayout(Setup)

Thanks, that makes sense. Obviously I'm new to B4A. I don't see in the IDE how to create a new Activity? I tried the File New menu but I think that created a new Project right?
 
Upvote 0
Top