1b - User Input

advertisement
Programming with App Inventor
Computing Institute for K-12 Teachers
Summer 2012 Workshop
User Input
Session SA-1
User Input
TextBox
 Input from the user can accomplished by using a TextBox
under the Basic Palette in the Designer.
 A single character, text string, number, alphanumeric string
maybe entered into the TextBox.
 A TextBox can be set to accept numbers only and/or be
multi-line input.
 The TextBox has many properties shown in the Properties
section of the Designer. These properties can be set at
design-time (in the Designer) or a run-time in the Blocks
Editor.
 The information entered by the user is stored in the .Text
attribute of the TextBox.
User Input
 To add a TextBox to your project select
the Palette and drag it to the Viewer screen.
TextBox
object from
User Input
TextBox
 A TextBox has two associated events: GotFocus and LostFocus.
When the .GotFocus event occurs it means the TextBox has been
selected and is ready to accept data. .LostFocus occurs when the
Textbox looses focus and will not accept data.
 A TextBox are often used in conjunction with a Label object. A
label is used to display information to a user. As its name implies,
a Label identifies what the user is to enter into the textbox.
 The string display show by a Label object is stored in the .Text
attribute (just as with the TextBox). The user cannot modify a
label.
 The string displayed by the label can be modified at both designtime via the Properties section of the Designer or at run-time with
the Blocks Editor.
User Input
 Shown here is a Label and a TextBox.
TextBox
Project 1 – User Input
 Create an app that asks the user to enter a piece of text,
using a button display have one label put the text in
uppercase, the second label takes a piece out of the text,
and the third label adds another text onto the original text.
Day 1 Questions
App Inventor Overview, Variables, Input
1.
What types of data (information) can a variable store?
2.
Name some of the basic objects that can be added to a project.
3.
Where can your programs be saved using the App Inventor?
4.
The App Inventor program consists of what three major components?
5.
Name one object that can be used to obtain input from a user.
6.
What type of input restriction can be enforced on a Text Box?
7.
What types of data can a TextBox accept if not restricted?
Day 1 Answer Key
App Inventor Overview, Variables, Input
1.
What types of data (information) can a variable store?
Number, Text (including alphanumeric) , Boolean
2.
Name some of the basic objects that can be added to a project.
Button, Canvas, CheckBox, Clock, Image, Label, ListPicker,
PasswordTextBox, TextBox, Sound, Ball, ImageSprite, Horizontal
Arrangement, TableArrangement, VerticleArrangement
3.
Where can your programs be saved using the App Inventor?
Online (to the Google App Inventor Servers), Your local computer hard
drive or other storage device
4.
The App Inventor program consists of what three major components?
App Inventor Designer, App Inventor Blocks Editor, Android Emulator
(or Android Phone)
5.
Name one object that can be used to obtain input from a user.
TextBox, ListPicker, Notifier
6.
What type of input restriction can be enforced on a Text Box?
TextBox can be restricted to accept only numeric input
7.
What types of data can a TextBox accept if not restricted?
Numbers, Text, Boolean
Download