Chapter 12
Handling User Input
In This Chapter
Working with EditText views
Creating date pickers and time pickers
Setting up alert dialogs
Validating user input
Rarely does an application not allow users to interact with it. Whether they use text, a date or time picker, a radio button, a check box, or any other input mechanism, users need to interact with your application in one way or another. This chapter focuses solely on user input in the form of alert confirmation, free‐form text, and dates and times.
Creating the User Input Interface
The most common input type is the EditText view, used for free‐form text entry. With 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.
Creating an EditText view
In Chapter 10, you created a view layout XML file, named fragment_task_edit.xml, that contained these lines of code:
<EditText
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
. . .
android:hint="@string/title"/> ...
Get Android App Development For Dummies, 3rd Edition 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.