Skip to the page
Year 8 · Summer 2 · Raid: App Forge

App Inventor: screens and components

PracticalPresent ▶

What this lesson covers

Topic 14 Programming further

KS3 Computing · Real programs keep data in lists, take text apart as strings, split work into subroutines, check their input, save to files, and get tested on purpose.

ProgrammingCambridge Lower Secondary Computing 0860

You will learn to

  • Identify the Designer and the Blocks editor in App Inventor, and what each one is for.
  • Create a screen with a label, a text box and a button.
  • Change a component's properties, like its text, size and colour.
  • Use the AI Companion app or the emulator to run your app.

Success criteria

  • I can drag a label, a text box and a button onto the screen.
  • I can change the text, font size and colour of a component.
  • I can give each component a clear name, like btnSay.
  • I can run my app on a phone or on the emulator.

Key words

Say each word, then read what it means. Every one is in the glossary too.

List
One name holding many values in order. Also called an array.
Index
An item's position in a list, counting from 0.
Subroutine
A named block of code you can call when needed.
Function
A subroutine that returns a value.
Parameter
A placeholder in a subroutine for a value passed in.
Validation
Checking input is reasonable before using it.
Boundary data
Test data at the very edge of what's allowed.

The explanation

Read it here, or open the study page below to go one step at a time with things to try.

Two halves: Designer and Blocks

MIT App Inventor is a free website for making phone apps. You build the code with blocks, like in Scratch.

It has two halves. Switch between them with the buttons at the top right.

HalfWhat you do thereLike in Scratch
DesignerBuild the screen. Drag on buttons, labels and pictures. Set how they look.Choosing sprites and costumes
BlocksSnap blocks together to say what the app does.The code area
★Remember

Designer = what the app looks like. Blocks = what the app does.

Components and properties

A component is one part of the app, like a button or a label.

A property is one setting of a component, like its text or its colour.

ComponentWhat it doesUseful properties
LabelShows text that the user cannot changeText, FontSize, TextColor
TextBoxA box the user can type inHint, Text
ButtonSomething to pressText, BackgroundColor, Width
ImageShows a picturePicture, Width, Height
  1. Find a component in the Palette on the left.
  2. Drag it onto the Viewer, the phone in the middle.
  3. Click it. Change its settings in the Properties panel on the right.
e.g.Example

A Scratch sprite has a size and a direction. An App Inventor button has a text and a colour. Both are properties.

Give every component a clear name

App Inventor names things Button1, Label1 and TextBox1. With ten buttons, that gets confusing.

Click Rename under the Components panel. Use a short tag for the type, then the job.

Name it getsBetter name
Button1btnSay
Label1lblGreeting
TextBox1txtName
?Why?

Why bother?

In the Blocks editor you see only the names. when btnSay.Click tells you what it does. when Button3.Click does not.

Test it on a phone

  1. Install the free MIT AI2 Companion app on a phone or tablet.
  2. In App Inventor, open the Connect menu and choose AI Companion. A QR code appears.
  3. Scan the code with the Companion app. Your app opens on the phone.
  4. Change something in the Designer. The phone updates by itself.
!Watch out

The phone and the computer must be on the same Wi-Fi network. If that does not work at school, use the Emulator.

The Emulator is a pretend phone on the computer screen. It needs a helper program called aiStarter installed first.

e.g.Worked example

Build the screen for a greeting app. It needs a place to type a name, a button, and a place to show the answer.

  1. Drag a TextBox onto the Viewer. Rename it txtName. Set its Hint to 'Type your name'.
  2. Drag a Button below it. Rename it btnSay. Set its Text to 'Say hello'.
  3. Drag a Label below that. Rename it lblGreeting. Set its FontSize to 24.
  4. Connect with the AI Companion. Check that all three show on the phone.
  5. The button does nothing yet. Next lesson, blocks will make it work.

Study it

Open the study page and go one step at a time.

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.