I Have a Dream - A

01

This is the "I Have a Dream" app, the first app you'll build for the Mobile CSP course. You'll learn that app building is a creative process. You will write code that plays Martin Luther King's "I Have a Dream" speech when the user touches the phone's screen.

Objectives:

Technical Terminology

Getting Ready

Navigating Among the Three Main Views

There are three main views that you will use in building apps. 

1. My Projects View

The My Projects View provides you with a list of your projects. To get to this view, click on the My Projects button. Use this view to create, upload, save, delete and otherwise manage your projects. To open the IHaveADreamStarter project, just click on its name. 

2. Designer View

Your project will open in the Designer View, which is used for designing the app's User Interface (UI).

Note: The Designer button is greyed out, because you are already in the Designer View.

As you can see, the Designer View contains five panels: 

Make sure you can identify each of these panels.

For the app shown here, the Screen1 component is selected in the Components panel and its properties are shown in the Properties panel. As the app designer, you can change the default values of the screen's title and other properties. 

3. Blocks Editor View

The Blocks Editor View is used to create the code blocks for your apps. To navigate to the Blocks Editor View, click on the Blocks button.

The Blocks View consist of two main panels:

Also at the bottom left of the Blocks view, all the media files are listed. 

The Blocks panel contains a list of Built-in blocks, which include blocks for doing Math, setting Colors, and other tasks. For example, if you click on "Math" you will see a drawer full with all of the various math operations that you can do in App Inventor. The Toolbox also contains a list of Component blocks. So far there is only the Screen1 component. If you click it you will see the various operations you can perform on that component. 

Video Tutorial


Text steps below.

User Interface

What is the app's user interface (UI)? It is that part of the app that interacts with the user. It includes any elements that the user can see, hear or feel. Designing an attractive and easy-to-use UI is an important part of building good mobile apps.

The user interface (UI) for our I Have a Dream app will consist of four Components, a Button, a Sound, and two Labels. Remember that this is done in the Designer View.

Your Viewer panel should look like this when your app is complete.

Adding a Label Component

Adding a Button Component

Click on its Text property and change it to an empty string by deleting "Text for Button1". 

Adding a Player (Sound) Component 

Coding the App's Behavior

It's time to get the app to play the speech when we touch its screen. For this we will be using the Blocks editor. So switch now to the Blocks Editor View. 

Event Driven Programming

Mobile apps use a style of programming known as event driven programming. An app's behavior depends on how the user programs the app to respond to various events. An example of an event would be when the user clicks on a button or when the phone's location changes or when a text message is received. We'll write apps that respond to all of these events. 

For the I Have a Dream app, there is only one event that we care about, the Button click event. 

This is an example of a when event block, which is also called an event handler block.

Notice that it has a empty do slot. When Button1 is clicked, the app will do whatever code we put into this slot.

We want it to play Martin Luther King's speech when the button is clicked. 

To summarize, whenever the user clicks on Button1, the app will respond by playing Player1's media file. This completes the coding of the I Have a Dream app.