android-components / mozilla.components.ui.autocomplete / InlineAutocompleteEditText

# InlineAutocompleteEditText

`open class InlineAutocompleteEditText : AppCompatEditText` (source)

A UI edit text component which supports inline autocompletion.

The background color of autocomplete spans can be configured using the custom autocompleteBackgroundColor attribute e.g. app:autocompleteBackgroundColor="#ffffff".

A filter listener (see setOnFilterListener) needs to be attached to provide autocomplete results. It will be invoked when the input text changes. The listener gets direct access to this component (via its view parameter), so it can call {@link applyAutocompleteResult} in return.

A commit listener (see setOnCommitListener) can be attached which is invoked when the user selected the result i.e. is done editing.

Various other listeners can be attached to enhance default behaviour e.g. setOnSelectionChangedListener and setOnWindowsFocusChangeListener which will be invoked in response to onSelectionChanged and onWindowFocusChanged respectively (see also setOnTextChangeListener, setOnSelectionChangedListener, and setOnWindowsFocusChangeListener).

### Types

AutocompleteResult | `data class AutocompleteResult`

### Constructors

<init> | `InlineAutocompleteEditText(ctx: Context, attrs: AttributeSet? = null, defStyleAttr: Int = R.attr.editTextStyle)` A UI edit text component which supports inline autocompletion.

### Properties

autocompleteResult | `var autocompleteResult: AutocompleteResult`
ctx | `val ctx: Context`
nonAutocompleteText | `val nonAutocompleteText: String`
originalText | `val originalText: String`

### Functions

applyAutocompleteResult | `fun applyAutocompleteResult(result: AutocompleteResult): Unit` Applies the provided result by updating the current autocomplete text and selection, if any.
onAttachedToWindow | `open fun onAttachedToWindow(): Unit`
onCreateInputConnection | `open fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection?` Code to handle deleting autocomplete first when backspacing. If there is no autocomplete text, both removeAutocomplete() and commitAutocomplete() are no-ops and return false. Therefore we can use them here without checking explicitly if we have autocomplete text or not.
onFocusChanged | `open fun onFocusChanged(gainFocus: Boolean, direction: Int, previouslyFocusedRect: Rect?): Unit`
onKeyPreIme | `open fun onKeyPreIme(keyCode: Int, event: KeyEvent): Boolean`
onSelectionChanged | `open fun onSelectionChanged(selStart: Int, selEnd: Int): Unit`
onTouchEvent | `open fun onTouchEvent(event: MotionEvent): Boolean`
onWindowFocusChanged | `open fun onWindowFocusChanged(hasFocus: Boolean): Unit`
sendAccessibilityEventUnchecked | `open fun sendAccessibilityEventUnchecked(event: AccessibilityEvent): Unit`
setOnCommitListener | `fun setOnCommitListener(l: OnCommitListener): Unit`
setOnFilterListener | `fun setOnFilterListener(l: OnFilterListener): Unit`
setOnKeyPreImeListener | `fun setOnKeyPreImeListener(l: OnKeyPreImeListener): Unit`
setOnSearchStateChangeListener | `fun setOnSearchStateChangeListener(l: OnSearchStateChangeListener): Unit`
setOnSelectionChangedListener | `fun setOnSelectionChangedListener(l: OnSelectionChangedListener): Unit`
setOnTextChangeListener | `fun setOnTextChangeListener(l: OnTextChangeListener): Unit`
setOnWindowsFocusChangeListener | `fun setOnWindowsFocusChangeListener(l: OnWindowsFocusChangeListener): Unit`
setText | `open fun setText(text: CharSequence?, type: BufferType): Unit`

### Companion Object Properties

AUTOCOMPLETE_SPAN | `val AUTOCOMPLETE_SPAN: Concrete`
DEFAULT_AUTOCOMPLETE_BACKGROUND_COLOR | `val DEFAULT_AUTOCOMPLETE_BACKGROUND_COLOR: Int`

### Extension Properties

isLTR | `val View.isLTR: Boolean` Is the horizontal layout direction of this view from Left to Right?
isRTL | `val View.isRTL: Boolean` Is the horizontal layout direction of this view from Right to Left?

### Extension Functions

hideKeyboard | `fun View.hideKeyboard(): Unit` Hides the soft input window.
isGone | `fun View.isGone(): Boolean` Returns true if this view's visibility is set to View.GONE.
isInvisible | `fun View.isInvisible(): Boolean` Returns true if this view's visibility is set to View.INVISIBLE.
isVisible | `fun View.isVisible(): Boolean` Returns true if this view's visibility is set to View.VISIBLE.
showKeyboard | `fun View.showKeyboard(flags: Int = InputMethodManager.SHOW_IMPLICIT): Unit` Tries to focus this view and show the soft input window for it.