How To Copy One Screen Into Other Screens In App Inventor

5,984 views
Skip to first unread message

Isaac Barber

unread,
Oct 23, 2015, 10:40:36 PM10/23/15
to MIT App Inventor Forum
Sometimes you have an app that has more than one screen with basically the same programming in each one. Instead of programming each screen separately I have a way to copy one screen and paste to all other screens. For instance, I have an app that locates restaurants for American Food, Mexican, Italian....etc. I programmed the first screen (American) and copied it and pasted on all the other screens and just changed a few minor details like About Screen and the Google commands in the blocks as well as the Title. Saves a lot of time!

Here's how:

1. Make sure you have the screens made by Adding Screens...for instance I made a blank screen for Mexican, Italian...etc.
2. Export aia to your computer
3. You must have 7zip installed on your computer for this to work. All copying must be inside 7zip to work. Download at http://www.7-zip.org/
4. Right click aia file and open archive with 7zip.
5. Click on src folder and open all until you see your pages with blk, scm, and yail.
6. Go to the blk file of the screen you want to copy. ex. American
7. Go to View
8. Notepad will open with xml file. Select All and Copy. Close notepad.
9. Go to next blk file you want to copy into ex. Mexican
10. Right click and view. Select All and Paste. Save. Close notepad. It will ask if you want to update, press ok.
11. Rinse and repeat for all files you want to copy into.
12. Next, go to scm file you wish to copy from. ex American.scm
13. Right click and view. Select All, Copy, Close notepad.
14. Go to file you wish to copy into. ex Mexican.scm
15. Select All and Paste.
16. Find where it says {"$Name":"Name Of Your Screen Name" ex. {"$Name":"American"
17. Change the screen name to the name of the screen you are pasting into. ex {"$Name":"Mexican"
18. Save, close notepad, and ok to update.
19. Rinse and repeat for all other scm screens. (except for the screens you don't want changed of course.)
20. Close 7zip window and go to where your file is located on your computer and right click and Rename.
21. Upload your aia file back onto app inventor.

The yail files do not need to be altered.

You are all set. Just change the information that needs to be changed on each page to suit the category!

Scott Ferguson

unread,
Oct 24, 2015, 2:32:14 AM10/24/15
to MIT App Inventor Forum
This has been a common request in the past.
It is nice to have how to do it in a short list.
I would add that if you are using Windows 7 or above, renaming the aia file extension to zip works with Windows file manager as an alternative requiring 7zip.
You would just change zip extension back to aia when done.
---
sf

Tim Carter

unread,
Oct 24, 2015, 10:15:00 AM10/24/15
to MIT App Inventor Forum
Thanks Isaac, a useful howto. Starred :)

Tim

Isaac Barber

unread,
Oct 24, 2015, 10:58:12 AM10/24/15
to MIT App Inventor Forum
Thanks Scott! Haven't tried it that way!

Isaac Barber

unread,
Oct 24, 2015, 10:58:38 AM10/24/15
to MIT App Inventor Forum
Thanks Tim!

Taifun

unread,
Oct 24, 2015, 11:52:56 AM10/24/15
to mitappinv...@googlegroups.com
Sometimes you have an app that has more than one screen with basically the same programming in each one. Instead of programming each screen separately I have a way to copy one screen and paste to all other screens.

before copying screens, my suggestion is to think about your design
probably you can use only one screen with the functionality and several screen arrangements to simulate different screens
this helps to avoid redundancy, keeps the total number of blocks as low as possible and simplifies maintaining your app
see also 

Taifun

Isaac Barber

unread,
Oct 25, 2015, 5:53:02 PM10/25/15
to MIT App Inventor Forum
If you have over 10 screens that is recommended. It's a pain to use one screen and program as suggested, for me anyway!

demetris christofi

unread,
Oct 25, 2015, 6:26:47 PM10/25/15
to MIT App Inventor Forum
From my personal experience, there are two sides of the same coin.

1)In one side, we can do what you suggest. Develop the first screen and then copy as many times as we want.
But, as others said in the past, this is risky and could lead to major problems.
I tried to copy a screen and after working several hours on the second screen, i could not build my app.
So, i imported an older backup of my work, before copying the screen and continued from there without further problems.

2)In the other side, it's more appropriate to use the same screen for similar functionalities and each time show/enable/select from lists, the elements you would like to use. This is what i am doing but currently i face an issue. After working on the same screen for a while, the app stuck and crashes. Not sure if it is because i overloaded the screen or other screen.

Generally, do no expect to be able to accomplish a lot using AI2. It is created for educational purposes and it is very limited.
I hope this will help people in the future.
Reply all
Reply to author
Forward
0 new messages