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.
In Chapter 11, you create a view layout XML file with the name of reminder_edit.xml that contains the following code:
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 three properties:
Because some devices do not have a physical keyboard, an onscreen keyboard must be present to interact with the input mechanisms. The EditText view is very versatile and its properties can be configured many ways. One of these properties is responsible for the display of the onscreen keyboard.
Why would you need to adjust the onscreen keyboard? It's simple: Different EditText input types sometimes need different keys. For example, if the EditText is a phone number, the onscreen keyboard should display numbers only. If the EditText value is an e-mail address, the onscreen keyboard should display common e-mail style attributes — such as the at symbol (@). The way you configure the onscreen keyboard can increase the usability of your application.
You configure the onscreen keyboard through the inputType property on the EditText view. This configuration offers far too many options for me to cover in this book, but if you like, you can review all of them at http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType.
3.149.27.234