Added in API level 1

MultiAutoCompleteTextView

open class MultiAutoCompleteTextView : AutoCompleteTextView
kotlin.Any
   ↳ android.view.View
   ↳ android.widget.TextView
   ↳ android.widget.EditText
   ↳ android.widget.AutoCompleteTextView
   ↳ android.widget.MultiAutoCompleteTextView

An editable text view, extending AutoCompleteTextView, that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing.

You must provide a Tokenizer to distinguish the various substrings.

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 savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.autocomplete_7);
 
          ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                  android.R.layout.simple_dropdown_item_1line, COUNTRIES);
          MultiAutoCompleteTextView textView = findViewById(R.id.edit);
          textView.setAdapter(adapter);
          textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
      }
 
      private static final String[] COUNTRIES = new String[] {
          "Belgium", "France", "Italy", "Germany", "Spain"
      };
  }

Summary

Nested classes
open

This simple Tokenizer can be used for lists where the items are separated by a comma and one or more spaces.

abstract

Inherited XML attributes
Inherited constants
Public constructors

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

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

Public methods
open Boolean

Instead of filtering whenever the total length of the text exceeds the threshhold, this subclass filters only when the length of the range from Tokenizer#findTokenStart to getSelectionEnd meets or exceeds getThreshold.

open CharSequence!

open Unit

Instead of validating the entire text, this subclass method validates each token of the text individually.

open Unit

Sets the Tokenizer that will be used to determine the relevant range of the text where the user is typing.

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

Instead of filtering on the entire contents of the edit box, this subclass method filters on the range from Tokenizer#findTokenStart to getSelectionEnd if the length of that range meets or exceeds getThreshold.

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

Starts filtering the content of the drop down list.

open Unit

Performs the text completion by replacing the range from Tokenizer#findTokenStart to getSelectionEnd by the the result of passing text through Tokenizer#terminateToken.

Inherited functions
Inherited properties

Public constructors

MultiAutoCompleteTextView

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

MultiAutoCompleteTextView

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

MultiAutoCompleteTextView

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

MultiAutoCompleteTextView

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

Public methods

enoughToFilter

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

Instead of filtering whenever the total length of the text exceeds the threshhold, this subclass filters only when the length of the range from Tokenizer#findTokenStart to getSelectionEnd meets or exceeds getThreshold.

getAccessibilityClassName

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

performValidation

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

Instead of validating the entire text, this subclass method validates each token of the text individually. Empty tokens are removed.

setTokenizer

Added in API level 1
open fun setTokenizer(t: MultiAutoCompleteTextView.Tokenizer!): Unit

Sets the Tokenizer that will be used to determine the relevant range of the text where the user is typing.

Protected methods

performFiltering

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

Instead of filtering on the entire contents of the edit box, this subclass method filters on the range from Tokenizer#findTokenStart to getSelectionEnd if the length of that range meets or exceeds getThreshold.

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.

performFiltering

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

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

replaceText

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

Performs the text completion by replacing the range from Tokenizer#findTokenStart to getSelectionEnd by the the result of passing text through Tokenizer#terminateToken. In addition, the replaced region will be marked as an AutoText substition so that if the user immediately presses DEL, the completion will be undone. Subclasses may override this method to do some different insertion of the content into the edit box.

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