Creating the User Input Interface

The most common input type is free-form text — known as an EditText widget. In other programming platforms, this is known as a text box. With an EditText widget, you can provide an onscreen keyboard or the user can elect to use the physical keyboard (if the device provides one) to enter input.

Creating an EditText widget

In Chapter 11, you create a view layout XML file with the name of reminder_edit.xml that contains the following code:

<EditText android:id=“@+id/title,”
    android:layout_width=“fill_parent”
    android:layout_height=“wrap_content” />

This snippet of code defines the text input for the title of the task. The snippet creates an input on the screen so that the user can type into it. This EditText widget spans the entire width of the screen and takes up only as much room as it needs in regard to height. When selected, Android automatically opens the onscreen keyboard to allow the user to enter some input on the screen. This example is minimalistic compared to the following EditText example, which is also created 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” />

Here, you create the body description text for the task. The layout width and height are the same as in the previous EditText widget, but the differences between these two widgets are outlined in the following ...

Get Android™ Tablet Application Development For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.