MIT App Inventor – A text entry example for beginners

When you build an Android app, you may need to work with text entered by the user. In this simple MIT App Inventor example, we’ll see how to process that text.

Difficulty: Beginner

Created: December 2021

Reviewed: November 2026

A simple Android app with text input

The ZIP files accompanying this article contain both the project file (.aia) and the installable app (.apk). I have only tried the apps on my own phone, so they have not been extensively tested. Install them at your own risk.

Build the app interface in Designer

First, drag two “HorizontalArrangement” layouts onto the screen. Put a “Label” in the first one to display the text. Add a “TextBox” and a “Button” to the second layout.

Then adjust each component in the “Properties” column. Feel free to experiment with colours, sizes and other settings.

MIT App Inventor Designer showing the English text input example
MIT App Inventor – text input example in Designer

Make the button work in the Blocks editor

When the interface is ready, switch to the Blocks editor. As you can see below, the blocks we need are not too complicated.

Add a “when Button1.Click” event block and connect an “if–else” block to it. This lets us check whether anything was entered in the text box when the button is pressed.

First, “trim” removes leading and trailing spaces from the text in “TextBox1”. Then “is empty” checks the result. If the input contains no text, we show “The input field is blank!” in “Label1”. Otherwise, we display the text entered in “TextBox1” there.

MIT App Inventor blocks checking whether the English text input is empty
MIT App Inventor – checking the text input in the Blocks editor

Test the Android app

Let’s try what we’ve built. In the web editor, choose “Connect” → “App Inventor Companion”. Open the “MIT AI2 Companion” app on your phone and scan the QR code.

English MIT App Inventor text input app on a phone
MIT App Inventor – text input example on a phone

Save the entered text with TinyDB

We can extend the app so that, the next time it starts, “Label1” shows the text that was displayed before the app closed. In Designer, add a “TinyDB” database component by dragging it onto the phone screen.

MIT App Inventor Designer with the TinyDB component
MIT App Inventor – adding TinyDB in Designer

Now return to the Blocks editor and modify the blocks as shown below.

MIT App Inventor blocks for saving and loading text with TinyDB
MIT App Inventor – saving and loading text with TinyDB

In the first group of blocks, the app reads the previously saved text from TinyDB when it starts and displays it in “Label1”. If nothing has been saved yet, for example on the first launch, “Label1” shows the default text instead.

The second group builds on our first example. If “TextBox1” is not empty, it saves the entered text in TinyDB under the “TextValue” tag and displays it in “Label1”. The app can then load that text the next time it starts.

Download the project files

TextBox_Example.zip

TextBoxDatabase_Example.zip


← More App Inventor tutorials