Android APIs
public class

EditText

extends TextView
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.EditText
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

EditText is a thin veneer over TextView that configures itself to be editable.

See the Text Fields guide.

XML attributes

See EditText Attributes, TextView Attributes, View Attributes

Summary

[Expand]
Inherited XML Attributes
From class android.widget.TextView
From class android.view.View
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
EditText(Context context)
EditText(Context context, AttributeSet attrs)
EditText(Context context, AttributeSet attrs, int defStyleAttr)
EditText(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
void extendSelection(int index)
CharSequence getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes.
Editable getText()
Return the text the TextView is displaying.
void selectAll()
Convenience for selectAll(Spannable).
void setEllipsize(TextUtils.TruncateAt ellipsis)
Causes words in the text that are longer than the view is wide to be ellipsized instead of broken in the middle.
void setSelection(int index)
Convenience for setSelection(Spannable, int).
void setSelection(int start, int stop)
void setText(CharSequence text, TextView.BufferType type)
Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.
Protected Methods
boolean getDefaultEditable()
Subclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.
MovementMethod getDefaultMovementMethod()
Subclasses override this to specify a default movement method.
[Expand]
Inherited Methods
From class android.widget.TextView
From class android.view.View
From class java.lang.Object
From interface android.view.ViewTreeObserver.OnPreDrawListener
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public EditText (Context context)

Added in API level 1

Parameters
context Context

public EditText (Context context, AttributeSet attrs)

Added in API level 1

Parameters
context Context
attrs AttributeSet

public EditText (Context context, AttributeSet attrs, int defStyleAttr)

Added in API level 1

Parameters
context Context
attrs AttributeSet
defStyleAttr int

public EditText (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Added in API level 21

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public Methods

public void extendSelection (int index)

Added in API level 1

Convenience for extendSelection(Spannable, int).

Parameters
index int

public CharSequence getAccessibilityClassName ()

Added in API level 23

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

Returns
CharSequence

public Editable getText ()

Added in API level 1

Return the text the TextView is displaying. If setText() was called with an argument of BufferType.SPANNABLE or BufferType.EDITABLE, you can cast the return value from this method to Spannable or Editable, respectively. Note: The content of the return value should not be modified. If you want a modifiable one, you should make your own copy first.

Returns
Editable

public void selectAll ()

Added in API level 1

Convenience for selectAll(Spannable).

public void setEllipsize (TextUtils.TruncateAt ellipsis)

Added in API level 1

Causes words in the text that are longer than the view is wide to be ellipsized instead of broken in the middle. You may also want to setSingleLine() or setHorizontallyScrolling(boolean) to constrain the text to a single line. Use null to turn off ellipsizing. If setMaxLines(int) has been used to set two or more lines, only END and MARQUEE are supported (other ellipsizing types will not do anything).

Parameters
ellipsis TextUtils.TruncateAt

public void setSelection (int index)

Added in API level 1

Convenience for setSelection(Spannable, int).

Parameters
index int

public void setSelection (int start, int stop)

Added in API level 1

Convenience for setSelection(Spannable, int, int).

Parameters
start int
stop int

public void setText (CharSequence text, TextView.BufferType type)

Added in API level 1

Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.

Parameters
text CharSequence
type TextView.BufferType

Protected Methods

protected boolean getDefaultEditable ()

Added in API level 1

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

Returns
boolean

protected MovementMethod getDefaultMovementMethod ()

Added in API level 1

Subclasses override this to specify a default movement method.

Returns
MovementMethod