O'Reilly logo

Android App Development For Dummies, 3rd Edition by 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

Chapter 12

Handling User Input

In This Chapter

arrow Working with EditText views

arrow Creating date pickers and time pickers

arrow Setting up alert dialogs

arrow 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"/> ...

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