AppCompatEditText
class AppCompatEditText : EditText, TintableBackgroundView, OnReceiveContentViewBehavior, EmojiCompatConfigurationView, TintableCompoundDrawablesView
| kotlin.Any | ||||
| ↳ | android.view.View | |||
| ↳ | android.widget.TextView | |||
| ↳ | android.widget.EditText | |||
| ↳ | androidx.appcompat.widget.AppCompatEditText |
EmojiAppCompatEditText |
AppCompatEditText widget enhanced with emoji capability by using |
GuidedActionAppCompatEditText |
A custom EditText that satisfies the IME key monitoring requirements of GuidedStepFragment. |
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
backgroundTintandbackgroundTintMode. - Allows setting a custom
listenerto 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
Public constructors |
|---|
AppCompatEditText(context: Context) |
AppCompatEditText(context: Context, attrs: AttributeSet?) |
AppCompatEditText(context: Context, attrs: AttributeSet?, defStyleAttr: Int) |
Public functions |
|
|---|---|
ActionMode.Callback? |
|
Editable? |
getText()Return the text that the view is displaying. |
TextClassifier |
@RequiresApi(api = 26)Returns the |
Boolean |
|
InputConnection? |
onCreateInputConnection(outAttrs: EditorInfo)If a |
Boolean |
onDragEvent(event: DragEvent!) |
ContentInfoCompat? |
onReceiveContent(payload: ContentInfoCompat)Implements the default behavior for receiving content, which coerces all content to text and inserts into the view. |
Boolean |
onTextContextMenuItem(id: Int)If a |
Unit |
setBackgroundDrawable(background: Drawable?)This function is deprecated. |
Unit |
setBackgroundResource(resId: @DrawableRes Int) |
Unit |
setCompoundDrawables( |
Unit |
setCompoundDrawablesRelative( |
Unit |
setCustomSelectionActionModeCallback( |
Unit |
setEmojiCompatEnabled(enabled: Boolean)Configure emoji fallback behavior using EmojiCompat. |
Unit |
setKeyListener(keyListener: KeyListener?)Adds EmojiCompat KeyListener to correctly edit multi-codepoint emoji when they've been converted to spans. |
Unit |
setTextAppearance(context: Context!, resId: Int)This function is deprecated. |
Unit |
@RequiresApi(api = 26)Sets the |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
AppCompatEditText
AppCompatEditText(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
Public functions
getCustomSelectionActionModeCallback
fun getCustomSelectionActionModeCallback(): ActionMode.Callback?
getText
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
@RequiresApi(api = 26)
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.
isEmojiCompatEnabled
fun isEmojiCompatEnabled(): Boolean
| Returns | |
|---|---|
Boolean |
the current enabled state, set via |
onCreateInputConnection
fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection?
If a listener is set, the returned InputConnection will use it to handle calls to commitContent.
onReceiveContent
fun onReceiveContent(payload: ContentInfoCompat): ContentInfoCompat?
Implements the default behavior for receiving content, which coerces all content to text and inserts into the view.
IMPORTANT: This method is provided to enable custom widgets that extend this class to customize the default behavior for receiving content. Apps wishing to provide custom behavior for receiving content should not override this method, but rather should set a listener via setOnReceiveContentListener. App code wishing to inject content into this view should not call this method directly, but rather should invoke performReceiveContent.
| Parameters | |
|---|---|
payload: ContentInfoCompat |
The content to insert and related metadata. |
| Returns | |
|---|---|
ContentInfoCompat? |
The portion of the passed-in content that was not handled (may be all, some, or none of the passed-in content). |
onTextContextMenuItem
fun onTextContextMenuItem(id: Int): Boolean
If a listener is set, uses it to execute the "Paste" and "Paste as plain text" menu actions.
setCompoundDrawables
fun setCompoundDrawables(
left: Drawable?,
top: Drawable?,
right: Drawable?,
bottom: Drawable?
): Unit
setCompoundDrawablesRelative
fun setCompoundDrawablesRelative(
start: Drawable?,
top: Drawable?,
end: Drawable?,
bottom: Drawable?
): Unit
setCustomSelectionActionModeCallback
fun setCustomSelectionActionModeCallback(
actionModeCallback: ActionMode.Callback?
): Unit
setEmojiCompatEnabled
fun setEmojiCompatEnabled(enabled: Boolean): Unit
Configure emoji fallback behavior using EmojiCompat. When enabled, this View will attempt to use EmojiCompat to enabled missing emojis. When disabled, this View will not display missing emojis using EmojiCompat. EmojiCompat must be correctly configured on a device for this to have an effect, which will happen by default if a correct downloadable fonts provider is installed on the device. If you manually configure EmojiCompat by calling EmojiCompat init after this View is constructed, you may call this method again to enable EmojiCompat on this text view. For more information about EmojiCompat configuration see the emoji2 module.
| Parameters | |
|---|---|
enabled: Boolean |
if true, display missing emoji using EmojiCompat, otherwise display missing emoji using a fallback glyph "□" (known as tofu) |
setKeyListener
fun setKeyListener(keyListener: KeyListener?): Unit
Adds EmojiCompat KeyListener to correctly edit multi-codepoint emoji when they've been converted to spans.
setTextClassifier
@RequiresApi(api = 26)
fun setTextClassifier(textClassifier: TextClassifier?): Unit
Sets the TextClassifier for this TextView.