Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

AppCompatEditText

open class AppCompatEditText : EditText, TintableBackgroundView
kotlin.Any
   ↳ 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 androidx.core.view.ViewCompat.
  • Allows setting of the background tint using R.attr#backgroundTint and R.attr#backgroundTintMode.

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

Public constructors

<init>(context: Context!)

<init>(context: Context!, attrs: AttributeSet!)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Public methods

open Editable?

Return the text that the view is displaying.

open TextClassifier

Returns the TextClassifier used by this TextView.

open InputConnection!

open Unit

open Unit
setBackgroundResource(@DrawableRes resId: Int)

open Unit

See TextViewCompat#setCustomSelectionActionModeCallback(TextView, ActionMode.Callback)

open Unit
setTextAppearance(context: Context!, resId: Int)

open Unit
setTextClassifier(@Nullable textClassifier: TextClassifier?)

Sets the TextClassifier for this TextView.

Protected methods

open Unit

Public constructors

<init>

AppCompatEditText(context: Context!)

<init>

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

<init>

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

Public methods

getText

@Nullable open fun getText(): Editable?

Return the text that the view is displaying. If an editable text has not been set yet, this will return null.

getTextClassifier

@NonNull open fun getTextClassifier(): TextClassifier

Returns the TextClassifier used by this TextView. If no TextClassifier has been set, this TextView uses the default set by the android.view.textclassifier.TextClassificationManager.

onCreateInputConnection

open fun onCreateInputConnection(outAttrs: EditorInfo!): InputConnection!

setBackgroundDrawable

open fun setBackgroundDrawable(background: Drawable!): Unit

setBackgroundResource

open fun setBackgroundResource(@DrawableRes resId: Int): Unit

setCustomSelectionActionModeCallback

open fun setCustomSelectionActionModeCallback(actionModeCallback: Callback!): Unit

See TextViewCompat#setCustomSelectionActionModeCallback(TextView, ActionMode.Callback)

setTextAppearance

open fun setTextAppearance(context: Context!, resId: Int): Unit

setTextClassifier

open fun setTextClassifier(@Nullable textClassifier: TextClassifier?): Unit

Sets the TextClassifier for this TextView.

Protected methods

drawableStateChanged

protected open fun drawableStateChanged(): Unit