Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

MultiAutoCompleteTextView

extends AutoCompleteTextView
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.EditText
         ↳ android.widget.AutoCompleteTextView
           ↳ android.widget.MultiAutoCompleteTextView

Class Overview

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 MultiAutoCompleteTextView.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 = (MultiAutoCompleteTextView) 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
class MultiAutoCompleteTextView.CommaTokenizer This simple Tokenizer can be used for lists where the items are separated by a comma and one or more spaces. 
interface MultiAutoCompleteTextView.Tokenizer  
[Expand]
Inherited XML Attributes
From class android.widget.AutoCompleteTextView
From class android.widget.TextView
From class android.view.View
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
MultiAutoCompleteTextView ( Context context)
MultiAutoCompleteTextView ( Context context, AttributeSet attrs)
MultiAutoCompleteTextView ( Context context, AttributeSet attrs, int defStyle)
Public Methods
boolean enoughToFilter ()
Instead of filtering whenever the total length of the text exceeds the threshhold, this subclass filters only when the length of the range from findTokenStart(CharSequence, int) to getSelectionEnd() meets or exceeds getThreshold() .
void onInitializeAccessibilityEvent ( AccessibilityEvent event)
Initializes an AccessibilityEvent with information about this View which is the event source.
void onInitializeAccessibilityNodeInfo ( AccessibilityNodeInfo info)
Initializes an AccessibilityNodeInfo with information about this view.
void performValidation ()
Instead of validating the entire text, this subclass method validates each token of the text individually.
void setTokenizer ( MultiAutoCompleteTextView.Tokenizer t)
Sets the Tokenizer that will be used to determine the relevant range of the text where the user is typing.
Protected Methods
void performFiltering ( CharSequence text, int start, int end, int keyCode)

Starts filtering the content of the drop down list.

void performFiltering ( CharSequence text, int keyCode)
Instead of filtering on the entire contents of the edit box, this subclass method filters on the range from findTokenStart(CharSequence, int) to getSelectionEnd() if the length of that range meets or exceeds getThreshold() .
void replaceText ( CharSequence text)

Performs the text completion by replacing the range from findTokenStart(CharSequence, int) to getSelectionEnd() by the the result of passing text through terminateToken(CharSequence) .

[Expand]
Inherited Methods
From class android.widget.AutoCompleteTextView
From class android.widget.EditText
From class android.widget.TextView
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewTreeObserver.OnPreDrawListener
From interface android.view.accessibility.AccessibilityEventSource
From interface android.widget.Filter.FilterListener

Public Constructors

public MultiAutoCompleteTextView ( Context context)

Added in API level 1

public MultiAutoCompleteTextView ( Context context, AttributeSet attrs)

Added in API level 1

public MultiAutoCompleteTextView ( Context context, AttributeSet attrs, int defStyle)

Added in API level 1

Public Methods

public boolean enoughToFilter ()

Added in API level 1

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

public void onInitializeAccessibilityEvent ( AccessibilityEvent event)

Initializes an AccessibilityEvent with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.

Example: Setting the password property of an event in addition to properties set by the super implementation:

          public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
     super.onInitializeAccessibilityEvent(event);
     event.setPassword(true);
 }
         

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

Parameters
event The event to initialize.

public void onInitializeAccessibilityNodeInfo ( AccessibilityNodeInfo info)

Parameters
info The instance to initialize.

public void performValidation ()

Added in API level 1

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

public void setTokenizer ( MultiAutoCompleteTextView.Tokenizer t)

Added in API level 1

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

Protected Methods

protected void performFiltering ( CharSequence text, int start, int end, int keyCode)

Added in API level 1

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 .

protected void performFiltering ( CharSequence text, int keyCode)

Added in API level 1

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

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

protected void replaceText ( CharSequence text)

Added in API level 1

Performs the text completion by replacing the range from findTokenStart(CharSequence, int) to getSelectionEnd() by the the result of passing text through terminateToken(CharSequence) . 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 the selected suggestion in the drop down list