Android EditText Customizing the InputType


Text fields can have different input types, such as number, date, password, or email address. The type determines what kind of characters are allowed inside the field, and may prompt the virtual keyboard to optimize its layout for frequently used characters.

By default, any text contents within an EditText control is displayed as plain text. By setting the inputType attribute, we can facilitate input of different types of information, like phone numbers and passwords:


Most common input types include:

textUriText that will be used as a URI
textEmailAddressText that will be used as an e-mail address
textPersonNameText that is the name of a person
textPasswordText that is a password that should be obscured
numberA numeric only field
phoneFor entering a phone number
dateFor entering a date
timeFor entering a time
textMultiLineAllow multiple lines of text in the field

The android:inputType also allows you to specify certain keyboard behaviors, such as whether to capitalize all new words or use features like auto-complete and spelling suggestions.
Here are some of the common input type values that define keyboard behaviors:

textCapSentencesNormal text keyboard that capitalizes the first letter for each new sentence
textCapWordsNormal text keyboard that capitalizes every word. Good for titles or person names
textAutoCorrectNormal text keyboard that corrects commonly misspelled words

You can set multiple inputType attributes if needed (separated by '|').

                       textNoSuggestions" />

You can see a list of all available input types here.