App Inventor and Multiple Screens


The recommended method of switching screens in App Inventor

Note: Before starting to create another screen, first you should think about is it really necessary? See also Building apps with many screens and SteveJG's post about advantages/disadvantages, because in only one screen you also can use vertical arrangements to simulate different screens, just set the arrangements to visible = true/false as needed...

See also Martyn_HK's example about how to use Tabs in App Inventor and another example from Cyd.


Note from the Colored Dots tutorial:
You can have many screens in an App Inventor app, but a screen always returns to the screen that opened it. On the other hand, you can get the effect of screens switching to arbitrary other screen by setting up a "manager screen" that is used for opening all the other screens. When a screen wants to switch, it returns to the manager with a value saying which screen to open next.

This version demonstrates the use of a manager screen. If in a screen you want to go to another screen, you always go back to the manager screen telling him where you want to go. With this method, there only is one screen active in any moment. Additionally the back button will be catched with the Screen.BackPressed block.

Note: if you only use the open another screen and never the close screen block, you will run out of memory after a while. Also reopening an already opened screen is a bad idea. For example if you open Screen1 twice, you also have to close your app twice!


You also might be interested in the following example: Tribblehunter's Multiple Screen Method

Some Notes

Let me share the feedback I received from Ian:
Just tried your manager app. It works fine but not in AI2 Companion. This runs Screen1.Initialize when it returns to screen1 and hence doesn't work properly. Also the only way to exit the app is to STOP AI2 Companion. Of course, that is perfectly reasonable but Just thought I'd let you know so that you can warn other users.
Thank you Ian!
Yes, the companion app has issues with multiple screens, see below. You have to build the app to see this working correctly.

Current limitations of the AI Companion app:

  1. The close screen block triggers the Initialize event instead of the OtherScreenClosed event.
  2. The close screen with value block triggers both the Initialize and OtherScreenClosed events instead of only the OtherScreenClosed event.
  3. The close application block does not work, a message 'Closing forms is not currently supported during development' will be displayed instead.

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

Screen1 (Manager Screen)


Screen2


Screen3


Download


Developing and maintaining snippets, tutorials and extensions for App Inventor takes a lot of time.
I hope it saved some of your time. If yes, then you might consider to donate a small amount!

Donation amount:

or donate some mBTC to Bitcoin Address:
1Jd8kXLHu2Vkuhi15TWHiQm4uE9AGPYxi8
Bitcoin

Thank you! Taifun
 

Download aia file for App Inventor
Back to top of page ...

Creative Commons License
This work by Pura Vida Apps is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.


Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact