

We might want to limit the total number of characters with: This would restrict the digits entered to just "0" and "1". You can limit the characters that can be entered into a field using the digits attribute: We might want to limit the entry to a single-line of text (avoid newlines):

You can see a list of all available input types here. You can set multiple inputType attributes if needed (separated by '|') Text, next button, and no microphone inputĪllow multiple lines of text in the field Text that is a password that should be obscured Text that will be used as an e-mail address By setting inputType, we can facilitate input of different types of information, like phone numbers and passwords: toString () Customizing the Input Typeīy default, any text contents within an EditText control is displayed as plain text. et_simple ) String strValue = simpleEditText. Getting the value of the text entered into an EditText is as follows: EditText simpleEditText = ( EditText ) findViewById ( R. Note that an EditText is simply a thin extension of the TextView and inherits all of the same properties. UsageĪn EditText is added to a layout with all default behaviors with the following XML: Check out the official text fields guide for even more input field details.

There are many important properties that can be set to customize the behavior of an EditText. If the user needs to enter text into an app, this is the primary way for them to do that. The EditText is the standard text entry widget in Android apps.
