Android Question Handling a lot of layout files

trueboss323

Active Member
Licensed User
Longtime User
Hey, so I have got a very basic question. On my app I have a lot of different layout files. Everytime the user presses a button on one layout file it loads the next one. In Visual Basic, we call these Forms. So my question is how can I make this easy? Like the user presses a button, it closes the current layout and loads the next one. On VB, the code would be like:

B4X:
Form2.Show
Me.Close

So how would I make it similar like in B4A?
 

trueboss323

Active Member
Licensed User
Longtime User
The problem with this code is that it takes a while to load the new activities. And this can be a pain, especially when going through a lot of layouts. Is there anyway to make the loading faster?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
To open a new Activity, StartActivity is the way (there also Intents, which are not more fast) and it is not slow.

If loading is slow, the problem may depend on what you load before the Activity is displayed (for example if you are connected to Internet to download something or if the layout to be loaded contains hundreds of views).
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Can you post your project (or send it to Erel)?
upload_2015-12-15_19-2-37.png
 
Upvote 0

trueboss323

Active Member
Licensed User
Longtime User
I have compiled a sample app. Please take a look at the file.
 

Attachments

  • IntelligenceTest.zip
    74.6 KB · Views: 131
Upvote 0

trueboss323

Active Member
Licensed User
Longtime User
Compared to using Activity.RemoveAllViews and Activity.LoadLayout, the loading is much faster. But then I would have to use a single Module for it, which would create a mess in the code.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Hey, so I have got a very basic question. On my app I have a lot of different layout files. Everytime the user presses a button on one layout file it loads the next one. In Visual Basic, we call these Forms. So my question is how can I make this easy
I think that the best solution is to use multiple activities.
 
Upvote 0
Top