App Inventor 2
Programming mobile phones with Android
by App Inventor 2 - Juan Antonio Villalpando
- Initiation Tutorial App Inventor 2 -
Return to tutorial index
____________________________
Storage
54B.- Passing data between screens. Another method.
ip54B_datas_between_screen
- Presentation.
- In the previous tutorial we saw that we could pass data through TinyDB comes screens. Let's see another method.
________________________________________
- In this example we will write a data in TextBox and click the button "Goto Screen". The current screen will close and the other screen data to be passed.
_________________
Design Screen1

_________________
Blocks Screen1
- Block: opens another screen with start value is in the part of Control .
- Block: get start value is in the part of Control.
- Block: when Screen1.Initialize is in the part of Screen1.

___________________________________
Add another window, click on Add Screen.
_________________
Design Screen2
- We set the background color of the Screen2 in Yellow to be easily distinguished.

_________________
Blocks Screen2
- Block: opens another screen with start value is in the part of Control.
- Block: get initial value is in the part of Control .
- Block: when Screen2.Initialize is in the part of Screen2.

______________________
Comments
- We send data from one screen to another.
- Note that the two variables: scr1 and scr2 are in both Screen.
- Sometimes the emulator does not work well with screen change, we must restart it .

_____________________________________
_____________________________________
_____________________________________
54C.- Pass several data between screens.
ip54c_dats_between_screen
- Presentation.
- In the previous tutorial we saw how to have a data from one screen to another, but ... what if we spend several data?
- Then we use a List.
We will forward name, age and city of one screen to another by the method we are seeing on this page.
In this case we created a List called data.
Insert the data: name old city
on the list.
We turn to the other screen Initial value is the data list.
On the screen Screen2 receive the data list of the previous screen.
We draw each item in the list and assign data to variables.
Every time we enter new data, the previous data is deleted from the list.
_________________
Design Screen1

_________________
Blocks Screen1

_________________
Design Screen2

_________________
Blocks Screen2

_______________________
Trick:
Sometimes we are making emulations to test the code and we need the input screen is updated. One trick is to pull out and put a new button anywhere on the screen and then delete it, so the Screen1 is updated.
__________________________________
|