Added in API level 1

EditText


open class EditText : TextView
kotlin.Any
   ↳ android.view.View
   ↳ android.widget.TextView
   ↳ android.widget.EditText

A user interface element for entering and modifying text. When you define an edit text widget, you must specify the android.R.styleable#TextView_inputType attribute. For example, for plain text input set inputType to "text":

<EditText
      android:id="@+id/plain_text_input"
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
      android:inputType="text"/>
Choosing the input type configures the keyboard type that is shown, acceptable characters, and appearance of the edit text. For example, if you want to accept a secret number, like a unique pin or serial number, you can set inputType to numberPassword. An input type of numberPassword results in an edit text that accepts numbers only, shows a numeric keyboard when focused, and masks the text that is entered for privacy.

See the Text Fields guide for examples of other android.R.styleable#TextView_inputType settings.

You also can receive callbacks as a user changes text by adding a android.text.TextWatcher to the edit text. This is useful when you want to add auto-save functionality as changes are made, or validate the format of user input, for example. You add a text watcher using the TextView.addTextChangedListener method.

This widget does not support auto-sizing text.

XML attributes

See EditText Attributes, TextView Attributes, View Attributes

Summary

XML attributes
android:enableTextStylingShortcuts Enables styling shortcuts, e.
Inherited XML attributes
Inherited constants
Public constructors
EditText(context: Context!)

EditText(context: Context!, attrs: AttributeSet!)

EditText(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

EditText(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit

Convenience for Selection.extendSelection.

open CharSequence!

Return the class name of this object to be used for accessibility purposes.

open Boolean

Return whether this text view is including its entire text contents in frozen icicles.

open Editable!

Return the text that TextView is displaying.

open Boolean

Return true if style shortcut is enabled, otherwise returns false.

open Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent!)

Called on the focused view when a key shortcut event is not handled.

open Boolean

Called when a context menu option for the text view is selected.

open Unit

Convenience for Selection.selectAll.

open Unit

Causes words in the text that are longer than the view's width to be ellipsized instead of broken in the middle.

open Unit
setSelection(index: Int)

Convenience for Selection.setSelection(Spannable, int).

open Unit
setSelection(start: Int, stop: Int)

Convenience for Selection.setSelection(Spannable, int, int).

open Unit

Enables styls shortcuts, e.

open Unit

Sets the text to be displayed and the android.widget.TextView.BufferType.

Protected methods
open Boolean

Subclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.

open MovementMethod!

Subclasses override this to specify a default movement method.

Inherited functions