Android 12 Developer Preview is here! Try it out, and give us your feedback!

AppCompatEditText

public class AppCompatEditText
extends EditText implements TintableBackgroundView, OnReceiveContentViewBehavior

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.EditText
         ↳ androidx.appcompat.widget.AppCompatEditText


A EditText which supports compatible features on older versions of the platform, including:

  • Allows dynamic tint of its background via the background tint methods in ViewCompat.
  • Allows setting of the background tint using R.attr.backgroundTint and R.attr.backgroundTintMode.
  • Allows setting a custom listener to handle insertion of content (e.g. pasting text or an image from the clipboard). This listener provides the opportunity to implement app-specific handling such as creating an attachment when an image is pasted.

This will automatically be used when you use EditText in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

Summary

Inherited constants

Inherited fields

Public constructors

AppCompatEditText(Context context)
AppCompatEditText(Context context, AttributeSet attrs)
AppCompatEditText(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

Editable getText()

Return the text that the view is displaying.

TextClassifier getTextClassifier()

Returns the TextClassifier used by this TextView.

InputConnection onCreateInputConnection(EditorInfo outAttrs)

If a listener is set, the returned InputConnection will use it to handle calls to InputConnection.commitContent(InputContentInfo, int, Bundle).

boolean onDragEvent(DragEvent event)
ContentInfoCompat onReceiveContent(ContentInfoCompat payload)

Implements the default behavior for receiving content, which coerces all content to text and inserts into the view.

boolean onTextContextMenuItem(int id)

If a listener is set, uses it to execute the "Paste" and "Paste as plain text" menu actions.

void setBackgroundDrawable(Drawable background)
void setBackgroundResource(int resId)
void setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback)

See TextViewCompat.setCustomSelectionActionModeCallback(TextView, ActionMode.Callback)

void setTextAppearance(Context context, int resId)
void setTextClassifier(TextClassifier textClassifier)

Sets the TextClassifier for this TextView.

Protected methods

void drawableStateChanged()

Inherited methods

Public constructors

AppCompatEditText

public AppCompatEditText (Context context)

Parameters
context Context

AppCompatEditText

public AppCompatEditText (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

</