Customizing the InputType

suggest change

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:

<EditText
    ...
    android:inputType="phone">
</EditText>

Most common input types include:

|Type | Description | |——————|———————————————––| |textUri | Text that will be used as a URI | |textEmailAddress | Text that will be used as an e-mail address | |textPersonName | Text that is the name of a person | |textPassword | Text that is a password that should be obscured | |number | A numeric only field | |phone | For entering a phone number | |date | For entering a date | |time | For entering a time | |textMultiLine | Allow 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:

|Type | Description | |——————|———————————————––| |textCapSentences | Normal text keyboard that capitalizes the first letter for each new sentence| |textCapWords | Normal text keyboard that capitalizes every word. Good for titles or person names| |textAutoCorrect | Normal text keyboard that corrects commonly misspelled words|

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

Example:

<EditText
    android:id="@+id/postal_address"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/postal_address_hint"
    android:inputType="textPostalAddress|
                       textCapWords|
                       textNoSuggestions" />

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


EditText:
* Customizing the InputType

Table Of Contents
2 Gradle
5 Intent
17 Service
19 WebView
31 SQLite
35 Glide
37 Dialog
38 ACRA
44 Handler
53 Toast
63 Menu
65 Picasso
70 Volley
71 Widgets
78 Realm
90 Spinner
95 OkHttp
108 TextView
109 ListView
111 Loader
118 Xposed
119 Security
121 ImageView
123 Doze Mode
130 Drawables
131 Colors
134 Fresco
139 AdMob
145 Keyboard
146 Button
150 EditText
155 Vk SDK
163 ExoPlayer
169 XMPP
175 OpenCV
177 Threads
184 ORMLite
186 TabLayout
190 LruCache
192 Zip files
194 Fastlane
199 FileIO
202 Moshi
210 VideoView
216 Paint
218 ProGuard
226 CleverTap
228 ADB shell
229 Ping ICMP
230 AIDL
234 Context
240 JCodec
242 Okio
249 FuseView
254 Looper
261 Fastjson
263 Jackson
267 Smartcard