O'Reilly logo

Android Application Development For Dummies, 2nd Edition by Donn Felker, Michael Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the User Input Interface

The most common input type is the EditText view, used for free-form text entry. Using an EditText view, you can provide an onscreen keyboard or let the user choose the physical keyboard (if the device provides one) to enter input.

remember.eps In case you’re familiar with other programming platforms, a text box performs the same function as an EditText view.

Creating an EditText view

In Chapter 9, you created a view layout XML file, named reminder_edit.xml, that contained these lines of code:

<EditText android:id=”@+id/title”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content” />

The snippet creates an input mechanism on the screen where the user can type a task title. The EditText view spans the width of the screen and occupies only as much height as it needs. When the view is selected, Android automatically opens the onscreen keyboard to allow user input.

The previous example takes a minimalistic approach, compared to the following EditText example, which is also present in the reminder_edit.xml layout file:

<EditText android:id=”@+id/body” android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

android:minLines=”5”

android:scrollbars=”vertical”

android:gravity=”top” />

This code creates the body description text of the task. The layout width and height are the same as in the EditText view in the previous example, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required