Android Guides | Samples

Android.Widget.AutoCompleteTextView Class

java Example

 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 Also: AutoCompleteTextView

Syntax

[Android.Runtime.Register("android/widget/AutoCompleteTextView", DoNotGenerateAcw=true)]
public class AutoCompleteTextView : EditText, Filter+IFilterListener, IDisposable

Remarks

java Example

 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"
     };
 }

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 AutoCompleteTextView.Threshold.

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

See the Text Fields guide.

[Android Documentation]

Requirements

Namespace: Android.Widget
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Widget.AutoCompleteTextView are listed below.

See Also: EditText

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

AdapterIListAdapter.
[read-only]
CompletionHintString.
[read-only]
CompletionHintFormattedICharSequence. Gets the optional hint text displayed at the bottom of the the matching list.
DropDownAnchorInt32.
[read-only]
DropDownBackgroundDrawable.
DropDownHeightInt32.
DropDownHorizontalOffsetInt32.
DropDownVerticalOffsetInt32.
DropDownWidthInt32.
[read-only]
IsPerformingCompletionBoolean. Identifies whether the view is currently performing a text completion, so subclasses can decide whether to respond to text changed events.
[read-only]
IsPopupShowingBoolean.
[read-only]
ItemClickListenerAdapterView+IOnItemClickListener.
[read-only]
ItemSelectedListenerAdapterView+IOnItemSelectedListener.
ListSelectionInt32. Get the position of the dropdown view selection, if there is one.
OnItemClickListenerAdapterView+IOnItemClickListener.
OnItemSelectedListenerAdapterView+IOnItemSelectedListener.
ThresholdInt32.
ValidatorAutoCompleteTextView+IValidator. Returns the Validator set with AutoCompleteTextView.Validator, or null if it was not set.

Protected Properties

[read-only]
FilterFilter. Returns the Filter obtained from IFilterable.Filter, or null if AutoCompleteTextView.setAdapter(T) was not called with a Filterable.
[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

ClearListSelection()
DismissDropDown()
EnoughToFilter() : Boolean
Returns true if the amount of text in the field meets or exceeds the AutoCompleteTextView.Threshold requirement.
OnFilterComplete(Int32)
PerformCompletion()
PerformValidation()
If a validator was set on this view and the current string is not valid, ask the validator to fix it.
SetCompletionHint(ICharSequence)
SetCompletionHint(String)
SetDropDownBackgroundDrawable(Drawable)
SetDropDownBackgroundResource(Int32)
SetOnDismissListener(AutoCompleteTextView+IOnDismissListener)
Set a listener that will be invoked whenever the AutoCompleteTextView's list of completions is dismissed.
SetText(ICharSequence, Boolean)
Like TextView.TextFormatted, except that it can disable filtering.
SetText(String, Boolean)
ShowDropDown()

Protected Methods

Public Events