Added in API level 1

AutoCompleteTextView


open class AutoCompleteTextView : EditText, Filter.FilterListener
kotlin.Any
   ↳ android.view.View
   ↳ android.widget.TextView
   ↳ android.widget.EditText
   ↳ android.widget.AutoCompleteTextView

An editable text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.

The drop down can be dismissed at any time by pressing the back key or, if no item is selected in the drop down, by pressing the enter/dpad center key.

The list of suggestions is obtained from a data adapter and appears only after a given number of characters defined by the threshold.

The following code snippet shows how to create a text view which suggests various countries names while the user is typing:

public class CountriesActivity extends Activity {
      protected void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.countries);
 
          ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                  android.R.layout.simple_dropdown_item_1line, COUNTRIES);
          AutoCompleteTextView textView = (AutoCompleteTextView)
                  findViewById(R.id.countries_list);
          textView.setAdapter(adapter);
      }
 
      private static final String[] COUNTRIES = new String[] {
          "Belgium", "France", "Italy", "Germany", "Spain"
      };
  }
  

See the Text Fields guide.

Summary

Nested classes
abstract

Listener to respond to the AutoCompleteTextView's completion list being dismissed.

abstract

This interface is used to make sure that the text entered in this TextView complies to a certain format.

XML attributes
android:completionHint Defines the hint displayed in the drop down menu.
android:completionHintView Defines the hint view displayed in the drop down menu.
android:completionThreshold Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu.
android:dropDownAnchor View to anchor the auto-complete dropdown to.
android:dropDownHeight Specifies the basic height of the dropdown.
android:dropDownHorizontalOffset Amount of pixels by which the drop down should be offset horizontally.
android:dropDownSelector Selector in a drop down list.
android:dropDownVerticalOffset Amount of pixels by which the drop down should be offset vertically.
android:dropDownWidth Specifies the basic width of the dropdown.
Inherited XML attributes
Inherited constants
Public constructors

Constructs a new auto-complete text view with the given context's theme.

Constructs a new auto-complete text view with the given context's theme and the supplied attribute set.

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

Constructs a new auto-complete text view with the given context's theme, the supplied attribute set, and default style attribute.

AutoCompleteTextView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Constructs a new auto-complete text view with the given context's theme, the supplied attribute set, and default styles.

AutoCompleteTextView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int, popupTheme: Resources.Theme!)

Constructs a new auto-complete text view with the given context, the supplied attribute set, default styles, and the theme against which the completion popup should be inflated.

Public methods
open Unit

Clear the list selection.

open Unit

Closes the drop down if present on screen.

open Boolean

Returns true if the amount of text in the field meets or exceeds the getThreshold requirement.

open CharSequence!

open ListAdapter!

Returns a filterable list adapter used for auto completion.

open CharSequence!

Gets the optional hint text displayed at the bottom of the the matching list.

open Int

Returns the id for the view that the auto-complete drop down list is anchored to.

open Drawable!

Gets the background of the auto-complete drop-down list.

open Int

Returns the current height for the auto-complete drop down list.

open Int

Gets the horizontal offset used for the auto-complete drop-down list.

open Int

Gets the vertical offset used for the auto-complete drop-down list.

open Int

Returns the current width for the auto-complete drop down list.

open Int

Returns the input method mode used by the auto complete dropdown.

open AdapterView.OnItemClickListener!

Returns the listener that is notified whenever the user clicks an item in the drop down list.

open AdapterView.OnItemSelectedListener!

Returns the listener that is notified whenever the user selects an item in the drop down list.

open Int

Get the position of the dropdown view selection, if there is one.

open AdapterView.OnItemClickListener!

Returns the listener that is notified whenever the user clicks an item in the drop down list.

open AdapterView.OnItemSelectedListener!

Returns the listener that is notified whenever the user selects an item in the drop down list.

open Int

Returns the number of characters the user must type before the drop down list is shown.

open AutoCompleteTextView.Validator!

Returns the Validator set with setValidator, or null if it was not set.

open Boolean

Identifies whether the view is currently performing a text completion, so subclasses can decide whether to respond to text changed events.

open Boolean

Indicates whether the popup menu is showing.

open Unit

open Unit

Notifies the end of a filtering operation.

open Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)

open Boolean
onKeyPreIme(keyCode: Int, event: KeyEvent!)

open Boolean
onKeyUp(keyCode: Int, event: KeyEvent!)

open Unit
onWindowFocusChanged(hasWindowFocus: Boolean)

open Unit

Performs the text completion by converting the selected item from the drop down list into a string, replacing the text box's content with this string and finally dismissing the drop down menu.

open Unit

If a validator was set on this view and the current string is not valid, ask the validator to fix it.

Unit

Refreshes the auto complete results.

open Unit
setAdapter(adapter: T)

Changes the list of data used for auto completion.

open Unit

Sets the optional hint text that is displayed at the bottom of the the matching list.

open Unit

Sets the view to which the auto-complete drop down list should anchor.

open Unit

Sets the background of the auto-complete drop-down list.

open Unit

Sets the background of the auto-complete drop-down list.

open Unit

Sets the current height for the auto-complete drop down list.

open Unit

Sets the horizontal offset used for the auto-complete drop-down list.

open Unit

Sets the vertical offset used for the auto-complete drop-down list.

open Unit

Sets the current width for the auto-complete drop down list.

open Unit

Use this method to specify when the IME should be displayed.

open Unit
setListSelection(position: Int)

Set the position of the dropdown view selection.

open Unit

open Unit

Set a listener that will be invoked whenever the AutoCompleteTextView's list of completions is dismissed.

open Unit

Sets the listener that will be notified when the user clicks an item in the drop down list.

open Unit

Sets the listener that will be notified when the user selects an item in the drop down list.

open Unit
setText(text: CharSequence!, filter: Boolean)

Like setText(java.lang.CharSequence), except that it can disable filtering.

open Unit
setThreshold(threshold: Int)

Specifies the minimum number of characters the user has to type in the edit box before the drop down list is shown.

open Unit

Sets the validator used to perform text validation.

open Unit

Displays the drop down on screen.

Protected methods
open CharSequence!
convertSelectionToString(selectedItem: Any!)

Converts the selected item from the drop down list into a sequence of character that can be used in the edit box.

open Filter!

Returns the Filter obtained from Filterable#getFilter, or null if setAdapter was not called with a Filterable.

open Unit

open Unit

open Unit

open Unit
onFocusChanged(focused: Boolean, direction: Int, previouslyFocusedRect: Rect?)

open Unit
performFiltering(text: CharSequence!, keyCode: Int)

Starts filtering the content of the drop down list.

open Unit

Performs the text completion by replacing the current text by the selected item.

open Boolean
setFrame(l: Int, t: Int, r: Int, b: Int)

Inherited functions
Inherited properties

XML attributes

android:completionHint

android:completionHint
Defines the hint displayed in the drop down menu.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:completionHintView

android:completionHintView
Defines the hint view displayed in the drop down menu.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:completionThreshold

android:completionThreshold
Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu.

May be an integer value, such as "100".

android:dropDownAnchor

android:dropDownAnchor
View to anchor the auto-complete dropdown to. If not specified, the text view itself is used.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:dropDownHeight

android:dropDownHeight
Specifies the basic height of the dropdown. Its value may be a dimension (such as "12dip") for a constant height, fill_parent or match_parent to fill the height of the screen, or wrap_content to match the height of the content of the drop down.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Must be one of the following constant values.

Constant Value Description
fill_parent ffffffff The dropdown should fit the height of the screen. This constant is deprecated starting from API Level 8 and is replaced by match_parent.
match_parent ffffffff The dropdown should fit the height of the screen. Introduced in API Level 8.
wrap_content fffffffe The dropdown should fit the height of the content.

android:dropDownHorizontalOffset

android:dropDownHorizontalOffset
Amount of pixels by which the drop down should be offset horizontally.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

android:dropDownSelector

android:dropDownSelector
Selector in a drop down list.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".

android:dropDownVerticalOffset

android:dropDownVerticalOffset
Amount of pixels by which the drop down should be offset vertically.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

android:dropDownWidth

android:dropDownWidth
Specifies the basic width of the dropdown. Its value may be a dimension (such as "12dip") for a constant width, fill_parent or match_parent to match the width of the screen, or wrap_content to match the width of the anchored view.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Must be one of the following constant values.

Constant Value Description
fill_parent ffffffff The dropdown should fill the width of the screen. This constant is deprecated starting from API Level 8 and is replaced by match_parent.
match_parent ffffffff The dropdown should fit the width of the screen. Introduced in API Level 8.
wrap_content fffffffe The dropdown should fit the width of its anchor.

Public constructors

AutoCompleteTextView

Added in API level 1
AutoCompleteTextView(context: Context!)

Constructs a new auto-complete text view with the given context's theme.

Parameters
context Context!: The Context the view is running in, through which it can access the current theme, resources, etc.

AutoCompleteTextView

Added in API level 1
AutoCompleteTextView(
    context: Context!,
    attrs: AttributeSet!)

Constructs a new auto-complete text view with the given context's theme and the supplied attribute set.

Parameters
context Context!: The Context the view is running in, through which it can access the current theme, resources, etc.
attrs AttributeSet!: The attributes of the XML tag that is inflating the view.

AutoCompleteTextView

Added in API level 1
AutoCompleteTextView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

Constructs a new auto-complete text view with the given context's theme, the supplied attribute set, and default style attribute.

Parameters
context Context!: The Context the view is running in, through which it can access the current theme, resources, etc.
attrs AttributeSet!: The attributes of the XML tag that is inflating the view.
defStyleAttr Int: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

AutoCompleteTextView

Added in API level 21
AutoCompleteTextView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Constructs a new auto-complete text view with the given context's theme, the supplied attribute set, and default styles.

Parameters
context Context!: The Context the view is running in, through which it can access the current theme, resources, etc.
attrs AttributeSet!: The attributes of the XML tag that is inflating the view.
defStyleAttr Int: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.
defStyleRes Int: A resource identifier of a style resource that supplies default values for the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.

AutoCompleteTextView

Added in API level 24
AutoCompleteTextView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int,
    popupTheme: Resources.Theme!)

Constructs a new auto-complete text view with the given context, the supplied attribute set, default styles, and the theme against which the completion popup should be inflated.

Parameters
context Context!: The context against which the view is inflated, which provides access to the current theme, resources, etc.
attrs AttributeSet!: The attributes of the XML tag that is inflating the view.
defStyleAttr Int: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.
defStyleRes Int: A resource identifier of a style resource that supplies default values for the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.
popupTheme Resources.Theme!: The theme against which the completion popup window should be inflated. May be null to use the view theme. If set, this will override any value specified by android.R.styleable#AutoCompleteTextView_popupTheme.

Public methods

clearListSelection

Added in API level 3
open fun clearListSelection(): Unit

Clear the list selection. This may only be temporary, as user input will often bring it back.

dismissDropDown

Added in API level 1
open fun dismissDropDown(): Unit

Closes the drop down if present on screen.

enoughToFilter

Added in API level 1
open fun enoughToFilter(): Boolean

Returns true if the amount of text in the field meets or exceeds the getThreshold requirement. You can override this to impose a different standard for when filtering will be triggered.

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

getAdapter

Added in API level 1
open fun getAdapter(): ListAdapter!

Returns a filterable list adapter used for auto completion.

Return
ListAdapter! a data adapter used for auto completion

getCompletionHint

Added in API level 16
open fun getCompletionHint(): CharSequence!

Gets the optional hint text displayed at the bottom of the the matching list.

Return
CharSequence! The hint text, if any

getDropDownAnchor

Added in API level 3
open fun getDropDownAnchor(): Int

Returns the id for the view that the auto-complete drop down list is anchored to.

Return
Int the view's id, or View#NO_ID if none specified

getDropDownBackground

Added in API level 5
open fun getDropDownBackground(): Drawable!

Gets the background of the auto-complete drop-down list.

Return
Drawable! the background drawable

getDropDownHeight

Added in API level 4
open fun getDropDownHeight(): Int

Returns the current height for the auto-complete drop down list. This can be a fixed width, or android.view.ViewGroup.LayoutParams#MATCH_PARENT to fill the screen, or android.view.ViewGroup.LayoutParams#WRAP_CONTENT to fit the width of its anchor view.

Return
Int the height for the drop down list

getDropDownHorizontalOffset

Added in API level 5
open fun getDropDownHorizontalOffset(): Int

Gets the horizontal offset used for the auto-complete drop-down list.

Return
Int the horizontal offset

getDropDownVerticalOffset

Added in API level 5
open fun getDropDownVerticalOffset(): Int

Gets the vertical offset used for the auto-complete drop-down list.

Return
Int the vertical offset

getDropDownWidth

Added in API level 3
open fun getDropDownWidth(): Int

Returns the current width for the auto-complete drop down list. This can be a fixed width, or android.view.ViewGroup.LayoutParams#MATCH_PARENT to fill the screen, or android.view.ViewGroup.LayoutParams#WRAP_CONTENT to fit the width of its anchor view.

Return
Int the width for the drop down list

getInputMethodMode

Added in API level 29
open fun getInputMethodMode(): Int

Returns the input method mode used by the auto complete dropdown.

Return
Int Value is android.widget.ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE, android.widget.ListPopupWindow#INPUT_METHOD_NEEDED, or android.widget.ListPopupWindow#INPUT_METHOD_NOT_NEEDED

getItemClickListener

Added in API level 1
Deprecated in API level 15
open fun getItemClickListener(): AdapterView.OnItemClickListener!

Deprecated: Use getOnItemClickListener() intead

Returns the listener that is notified whenever the user clicks an item in the drop down list.

Return
AdapterView.OnItemClickListener! the item click listener

getItemSelectedListener

Added in API level 1
Deprecated in API level 15
open fun getItemSelectedListener(): AdapterView.OnItemSelectedListener!

Deprecated: Use getOnItemSelectedListener() intead

Returns the listener that is notified whenever the user selects an item in the drop down list.

Return
AdapterView.OnItemSelectedListener! the item selected listener

getListSelection

Added in API level 3
open fun getListSelection(): Int

Get the position of the dropdown view selection, if there is one. Returns ListView.INVALID_POSITION if there is no dropdown or if there is no selection.

Return
Int the position of the current selection, if there is one, or ListView.INVALID_POSITION if not.

getOnItemClickListener

Added in API level 3
open fun getOnItemClickListener(): AdapterView.OnItemClickListener!

Returns the listener that is notified whenever the user clicks an item in the drop down list.

Return
AdapterView.OnItemClickListener! the item click listener

getOnItemSelectedListener

Added in API level 3
open fun getOnItemSelectedListener(): AdapterView.OnItemSelectedListener!

Returns the listener that is notified whenever the user selects an item in the drop down list.

Return
AdapterView.OnItemSelectedListener! the item selected listener

getThreshold

Added in API level 1
open fun getThreshold(): Int

Returns the number of characters the user must type before the drop down list is shown.

Return
Int the minimum number of characters to type to show the drop down

getValidator

Added in API level 1
open fun getValidator(): AutoCompleteTextView.Validator!

Returns the Validator set with setValidator, or null if it was not set.

isPerformingCompletion

Added in API level 3
open fun isPerformingCompletion(): Boolean

Identifies whether the view is currently performing a text completion, so subclasses can decide whether to respond to text changed events.

isPopupShowing

Added in API level 1
open fun isPopupShowing(): Boolean

Indicates whether the popup menu is showing.

Return
Boolean true if the popup menu is showing, false otherwise

onCommitCompletion

Added in API level 3
open fun onCommitCompletion(completion: CompletionInfo!): Unit
Parameters
text The auto complete text the user has selected.

onFilterComplete

Added in API level 1
open fun onFilterComplete(count: Int): Unit

Notifies the end of a filtering operation.

Parameters
count Int: the number of values computed by the filter

onKeyDown

Added in API level 1
open fun onKeyDown(
    keyCode: Int,
    event: KeyEvent!
): Boolean
Parameters
keyCode Int: a key code that represents the button pressed, from android.view.KeyEvent
event KeyEvent!: the KeyEvent object that defines the button action
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyPreIme

Added in API level 3
open fun onKeyPreIme(
    keyCode: Int,
    event: KeyEvent!
): Boolean
Parameters
keyCode Int: The value in event.getKeyCode().
event KeyEvent!: Description of the key event.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyUp

Added in API level 1
open fun onKeyUp(
    keyCode: Int,
    event: KeyEvent!
): Boolean
Parameters
keyCode Int: A key code that represents the button pressed, from android.view.KeyEvent.
event KeyEvent!: The KeyEvent object that defines the button action.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onWindowFocusChanged

Added in API level 1
open fun onWindowFocusChanged(hasWindowFocus: Boolean): Unit
Parameters
hasWindowFocus Boolean: True if the window containing this view now has focus, false otherwise.

performCompletion

Added in API level 1
open fun performCompletion(): Unit

Performs the text completion by converting the selected item from the drop down list into a string, replacing the text box's content with this string and finally dismissing the drop down menu.

performValidation

Added in API level 1
open fun performValidation(): Unit

If a validator was set on this view and the current string is not valid, ask the validator to fix it.

refreshAutoCompleteResults

Added in API level 29
fun refreshAutoCompleteResults(): Unit

Refreshes the auto complete results. You usually shouldn't have to manually refresh the AutoCompleteResults as this is done automatically whenever the text changes. However if the results are not available and have to be fetched, you can call this function after fetching the results.

setAdapter

Added in API level 1
open fun <T> setAdapter(adapter: T): Unit where T : ListAdapter!, T : Filterable!

Changes the list of data used for auto completion. The provided list must be a filterable list adapter.

The caller is still responsible for managing any resources used by the adapter. Notably, when the AutoCompleteTextView is closed or released, the adapter is not notified. A common case is the use of android.widget.CursorAdapter, which contains a android.database.Cursor that must be closed. This can be done automatically (see startManagingCursor()), or by manually closing the cursor when the AutoCompleteTextView is dismissed.

Parameters
adapter T: the adapter holding the auto completion data

setCompletionHint

Added in API level 1
open fun setCompletionHint(hint: CharSequence!): Unit

Sets the optional hint text that is displayed at the bottom of the the matching list. This can be used as a cue to the user on how to best use the list, or to provide extra information.

Parameters
hint CharSequence!: the text to be displayed to the user

setDropDownAnchor

Added in API level 3
open fun setDropDownAnchor(id: Int): Unit

Sets the view to which the auto-complete drop down list should anchor. The view corresponding to this id will not be loaded until the next time it is needed to avoid loading a view which is not yet instantiated.

Parameters
id Int: the id to anchor the drop down list view to

setDropDownBackgroundDrawable

Added in API level 5
open fun setDropDownBackgroundDrawable(d: Drawable!): Unit

Sets the background of the auto-complete drop-down list.

Parameters
d Drawable!: the drawable to set as the background

setDropDownBackgroundResource

Added in API level 5
open fun setDropDownBackgroundResource(id: Int): Unit

Sets the background of the auto-complete drop-down list.

Parameters
id Int: the id of the drawable to set as the background

setDropDownHeight

Added in API level 4
open fun setDropDownHeight(height: Int): Unit

Sets the current height for the auto-complete drop down list. This can be a fixed width, or android.view.ViewGroup.LayoutParams#MATCH_PARENT to fill the screen, or android.view.ViewGroup.LayoutParams#WRAP_CONTENT to fit the width of its anchor view.

Parameters
height Int: the height to use

setDropDownHorizontalOffset

Added in API level 5
open fun setDropDownHorizontalOffset(offset: Int): Unit

Sets the horizontal offset used for the auto-complete drop-down list.

Parameters
offset Int: the horizontal offset

setDropDownVerticalOffset

Added in API level 5
open fun setDropDownVerticalOffset(offset: Int): Unit

Sets the vertical offset used for the auto-complete drop-down list.

Parameters
offset Int: the vertical offset

setDropDownWidth

Added in API level 3
open fun setDropDownWidth(width: Int): Unit

Sets the current width for the auto-complete drop down list. This can be a fixed width, or android.view.ViewGroup.LayoutParams#MATCH_PARENT to fill the screen, or android.view.ViewGroup.LayoutParams#WRAP_CONTENT to fit the width of its anchor view.

Parameters
width Int: the width to use

setInputMethodMode

Added in API level 29
open fun setInputMethodMode(mode: Int): Unit

Use this method to specify when the IME should be displayed. This function can be used to prevent the dropdown from obscuring the IME.

Parameters
mode Int: speficies the input method mode. use one of the following values: ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE IME Displayed if the auto-complete box is focusable. ListPopupWindow#INPUT_METHOD_NEEDED Always display the IME. ListPopupWindow#INPUT_METHOD_NOT_NEEDED. The auto-complete suggestions are always displayed, even if the suggestions cover/hide the input method. Value is android.widget.ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE, android.widget.ListPopupWindow#INPUT_METHOD_NEEDED, or android.widget.ListPopupWindow#INPUT_METHOD_NOT_NEEDED

setListSelection

Added in API level 3
open fun setListSelection(position: Int): Unit

Set the position of the dropdown view selection.

Parameters
position Int: The position to move the selector to.

setOnClickListener

Added in API level 1
open fun setOnClickListener(listener: View.OnClickListener?): Unit
Parameters
l The callback that will run This value may be null.

setOnDismissListener

Added in API level 17
open fun setOnDismissListener(dismissListener: AutoCompleteTextView.OnDismissListener!): Unit

Set a listener that will be invoked whenever the AutoCompleteTextView's list of completions is dismissed.

Parameters
dismissListener AutoCompleteTextView.OnDismissListener!: Listener to invoke when completions are dismissed

setOnItemClickListener

Added in API level 1
open fun setOnItemClickListener(l: AdapterView.OnItemClickListener!): Unit

Sets the listener that will be notified when the user clicks an item in the drop down list.

Parameters
l AdapterView.OnItemClickListener!: the item click listener

setOnItemSelectedListener

Added in API level 1
open fun setOnItemSelectedListener(l: AdapterView.OnItemSelectedListener!): Unit

Sets the listener that will be notified when the user selects an item in the drop down list.

Parameters
l AdapterView.OnItemSelectedListener!: the item selected listener

setText

Added in API level 17
open fun setText(
    text: CharSequence!,
    filter: Boolean
): Unit

Like setText(java.lang.CharSequence), except that it can disable filtering.

Parameters
filter Boolean: If false, no filtering will be performed as a result of this call.

setThreshold

Added in API level 1
open fun setThreshold(threshold: Int): Unit

Specifies the minimum number of characters the user has to type in the edit box before the drop down list is shown.

When threshold is less than or equals 0, a threshold of 1 is applied.

Parameters
threshold Int: the number of characters to type before the drop down is shown

See Also

setValidator

Added in API level 1
open fun setValidator(validator: AutoCompleteTextView.Validator!): Unit

Sets the validator used to perform text validation.

Parameters
validator AutoCompleteTextView.Validator!: The validator used to validate the text entered in this widget.

showDropDown

Added in API level 1
open fun showDropDown(): Unit

Displays the drop down on screen.

Protected methods

convertSelectionToString

Added in API level 1
protected open fun convertSelectionToString(selectedItem: Any!): CharSequence!

Converts the selected item from the drop down list into a sequence of character that can be used in the edit box.

Parameters
selectedItem Any!: the item selected by the user for completion
Return
CharSequence! a sequence of characters representing the selected suggestion

getFilter

Added in API level 1
protected open fun getFilter(): Filter!

Returns the Filter obtained from Filterable#getFilter, or null if setAdapter was not called with a Filterable.

onAttachedToWindow

Added in API level 1
protected open fun onAttachedToWindow(): Unit

onDetachedFromWindow

Added in API level 1
protected open fun onDetachedFromWindow(): Unit

onDisplayHint

Added in API level 8
protected open fun onDisplayHint(hint: Int): Unit
Parameters
hint Int: A hint about whether or not this view is displayed: VISIBLE or INVISIBLE. Value is android.view.View#VISIBLE, android.view.View#INVISIBLE, or android.view.View#GONE

onFocusChanged

Added in API level 1
protected open fun onFocusChanged(
    focused: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect?
): Unit
Parameters
gainFocus True if the View has focus; false otherwise.
direction Int: The direction focus has moved when requestFocus() is called to give this view focus. Values are FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, or FOCUS_BACKWARD. It may not always apply, in which case use the default. Value is android.view.View#FOCUS_BACKWARD, android.view.View#FOCUS_FORWARD, android.view.View#FOCUS_LEFT, android.view.View#FOCUS_UP, android.view.View#FOCUS_RIGHT, or android.view.View#FOCUS_DOWN
previouslyFocusedRect Rect?: The rectangle, in this view's coordinate system, of the previously focused view. If applicable, this will be passed in as finer grained information about where the focus is coming from (in addition to direction). Will be null otherwise.

performFiltering

Added in API level 1
protected open fun performFiltering(
    text: CharSequence!,
    keyCode: Int
): Unit

Starts filtering the content of the drop down list. The filtering pattern is the content of the edit box. Subclasses should override this method to filter with a different pattern, for instance a substring of text.

Parameters
text CharSequence!: the filtering pattern
keyCode Int: the last character inserted in the edit box; beware that this will be null when text is being added through a soft input method.

replaceText

Added in API level 1
protected open fun replaceText(text: CharSequence!): Unit

Performs the text completion by replacing the current text by the selected item. Subclasses should override this method to avoid replacing the whole content of the edit box.

Parameters
text CharSequence!: the selected suggestion in the drop down list

setFrame

Added in API level 1
protected open fun setFrame(
    l: Int,
    t: Int,
    r: Int,
    b: Int
): Boolean