Android EditText inputType - XML formatting examples, options

When using Android with "soft" touchscreen keyboards, you can change how the keyboard looks, and how the EditText widget works by specifying an inputType when you create your EditText widget.

According to the book, Beginning Android 3, the inputType field can be broken down into these major classes:

  • text
  • number
  • phone
  • datetime
  • date
  • time

EditText inputType XML configuration examples

This is only part of the story though. You also need to know that (a) these main classes have many subclasses, and (b) you can combine inputType options in your XML specifications to create the effect you want. For instance, from the same book, here's an EditText field for an email address:

<EditText android:inputType="text|textEmailAddress" />

This one looks for signed decimal numbers:

<EditText android:inputType="number|numberSigned|numberDecimal" />

Here's a date text field:

<EditText android:inputType="date" />

And here's a multiline text field with spelling auto-correct:

<EditText android:inputType="text|textMultilLine|textAutoCorrect" />

More information

For many more Android EditText inputType options, see the Android InputType documentation page.

The book Beginning Android 3 is also excellent, and I highly recommend it.