# MaterialAutoCompleteTextView

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/textfield/MaterialAutoCompleteTextView.java)

*** ** * ** ***


```
public class MaterialAutoCompleteTextView
```

<br />

*** ** * ** ***

A special sub-class of android.widget.AutoCompleteTextView that is auto-inflated so that auto-complete text fields (e.g., for an Exposed Dropdown Menu) are accessible when being interacted through a screen reader.

The ListPopupWindow of the android.widget.AutoCompleteTextView is not modal, so it does not grab accessibility focus. The `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView` changes that by having a modal ListPopupWindow that is displayed instead of the non-modal one, so that the first item of the popup is automatically focused. This simulates the behavior of the android.widget.Spinner.

## Summary

| ### Public fields |
|---|---|
| `final float` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#popupElevation()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#simpleItemSelectedColor()` |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#simpleItemSelectedRippleColor()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#MaterialAutoCompleteTextView(Context)(Context context)` |
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#MaterialAutoCompleteTextView(Context,AttributeSet)( Context context, AttributeSet attributeSet )` |
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#MaterialAutoCompleteTextView(Context,AttributeSet,int)( Context context, AttributeSet attributeSet, int defStyleAttr )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#dismissDropDown()()` |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getDropDownBackgroundTintList()()` Returns the color of the popup dropdown container. |
| `https://developer.android.com/reference/java/lang/CharSequence` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getHint()()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getPopupElevation()()` Returns the elevation of the dropdown popup. |
| `int` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getSimpleItemSelectedColor()()` Returns the color of the default selected popup dropdown item. |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getSimpleItemSelectedRippleColor()()` Returns the ripple color of the default selected popup dropdown item, or null if not set. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#isPopupShowing()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#onKeyDown(int,KeyEvent)(int keyCode, KeyEvent event)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#onWindowFocusChanged(boolean)(boolean hasWindowFocus)` |
| `void` | `<T extends ListAdapter & Filterable> https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setAdapter(T)(T adapter)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setDropDownBackgroundDrawable(Drawable)(Drawable d)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setDropDownBackgroundTint(int)(int dropDownBackgroundColor)` Sets the color of the popup dropdown container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setDropDownBackgroundTintList(ColorStateList)(ColorStateList dropDownBackgroundTint)` Sets the color of the popup dropdown container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setOnItemSelectedListener(OnItemSelectedListener)(OnItemSelectedListener listener)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setRawInputType(int)(int type)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItemSelectedColor(int)(int simpleItemSelectedColor)` Sets the color of the default selected popup dropdown item to be used along with `R.attr.simpleItemLayout`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItemSelectedRippleColor(ColorStateList)( ColorStateList simpleItemSelectedRippleColor )` Sets the ripple color of the selected popup dropdown item to be used along with `R.attr.simpleItemLayout`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItems(java.lang.String[])(String[] stringArray)` Sets the simple string items of auto-completion with the given string array. |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItems(int)(int stringArrayResId)` Sets the simple string items of auto-completion with the given string array resource. |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#showDropDown()()` |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#onAttachedToWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#onDetachedFromWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#onMeasure(int,int)(int widthMeasureSpec, int heightMeasureSpec)` |

## Public fields

### popupElevation

```
public final float popupElevation
```

### simpleItemSelectedColor

```
public int simpleItemSelectedColor
```

### simpleItemSelectedRippleColor

```
public ColorStateList simpleItemSelectedRippleColor
```

## Public constructors

### MaterialAutoCompleteTextView

```
public MaterialAutoCompleteTextView(Context context)
```

### MaterialAutoCompleteTextView

```
public MaterialAutoCompleteTextView(
    Context context,
    AttributeSet attributeSet
)
```

### MaterialAutoCompleteTextView

```
public MaterialAutoCompleteTextView(
    Context context,
    AttributeSet attributeSet,
    int defStyleAttr
)
```

## Public methods

### dismissDropDown

```
public void dismissDropDown()
```

### getDropDownBackgroundTintList

```
public ColorStateList getDropDownBackgroundTintList()
```

Returns the color of the popup dropdown container.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_dropDownBackgroundTint

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setDropDownBackgroundTint(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setDropDownBackgroundTintList(ColorStateList)` |   |

### getHint

```
public CharSequence getHint()
```

### getPopupElevation

```
public float getPopupElevation()
```

Returns the elevation of the dropdown popup.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_android_popupElevation

### getSimpleItemSelectedColor

```
public int getSimpleItemSelectedColor()
```

Returns the color of the default selected popup dropdown item.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_simpleItemSelectedColor

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItemSelectedColor(int)` |   |

### getSimpleItemSelectedRippleColor

```
public ColorStateList getSimpleItemSelectedRippleColor()
```

Returns the ripple color of the default selected popup dropdown item, or null if not set.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_simpleItemSelectedRippleColor

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItemSelectedRippleColor(ColorStateList)` |   |

### isPopupShowing

```
public boolean isPopupShowing()
```

### onKeyDown

```
public boolean onKeyDown(int keyCode, KeyEvent event)
```

### onWindowFocusChanged

```
public void onWindowFocusChanged(boolean hasWindowFocus)
```

### setAdapter

```
public void <T extends ListAdapter & Filterable> setAdapter(T adapter)
```

### setDropDownBackgroundDrawable

```
public void setDropDownBackgroundDrawable(Drawable d)
```

### setDropDownBackgroundTint

```
public void setDropDownBackgroundTint(int dropDownBackgroundColor)
```

Sets the color of the popup dropdown container. It will take effect only if the popup background is a `https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable`, which is the default when using a Material theme.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_dropDownBackgroundTint

| Parameters |
|---|---|
| `int dropDownBackgroundColor` | the popup dropdown container color |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setDropDownBackgroundTintList(ColorStateList)` |   |
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getDropDownBackgroundTintList()` |   |

### setDropDownBackgroundTintList

```
public void setDropDownBackgroundTintList(ColorStateList dropDownBackgroundTint)
```

Sets the color of the popup dropdown container. It will take effect only if the popup background is a `https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable`, which is the default when using a Material theme.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_dropDownBackgroundTint

| Parameters |
|---|---|
| `ColorStateList dropDownBackgroundTint` | the popup dropdown container tint as a ColorStateList object. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setDropDownBackgroundTint(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getDropDownBackgroundTintList()` |   |

### setOnItemSelectedListener

```
public void setOnItemSelectedListener(OnItemSelectedListener listener)
```

### setRawInputType

```
public void setRawInputType(int type)
```

### setSimpleItemSelectedColor

```
public void setSimpleItemSelectedColor(int simpleItemSelectedColor)
```

Sets the color of the default selected popup dropdown item to be used along with `R.attr.simpleItemLayout`.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_simpleItemSelectedColor

| Parameters |
|---|---|
| `int simpleItemSelectedColor` | the selected item color |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getSimpleItemSelectedColor()` |   |
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItems(int)` |   |

### setSimpleItemSelectedRippleColor

```
public void setSimpleItemSelectedRippleColor(
    ColorStateList simpleItemSelectedRippleColor
)
```

Sets the ripple color of the selected popup dropdown item to be used along with `R.attr.simpleItemLayout`.

ref com.google.android.material.R.styleable#MaterialAutoCompleteTextView_simpleItemSelectedRippleColor

| Parameters |
|---|---|
| `ColorStateList simpleItemSelectedRippleColor` | the ripple color state list |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#getSimpleItemSelectedRippleColor()` |   |
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItems(int)` |   |

### setSimpleItems

```
public void setSimpleItems(String[] stringArray)
```

Sets the simple string items of auto-completion with the given string array. This method will create a default ArrayAdapter with a default item layout specified by `R.attr.simpleItemLayout` to display auto-complete items.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItems(int)` |   |
| `https://developer.android.com/reference/[JVM root]/setAdapter(ListAdapter)` |   |

### setSimpleItems

```
public void setSimpleItems(int stringArrayResId)
```

Sets the simple string items of auto-completion with the given string array resource. This method will create a default ArrayAdapter with a default item layout specified by `R.attr.simpleItemLayout` to display auto-complete items.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/textfield/MaterialAutoCompleteTextView#setSimpleItems(java.lang.String[])` |   |
| `https://developer.android.com/reference/[JVM root]/setAdapter(ListAdapter)` |   |

### showDropDown

```
public void showDropDown()
```

## Protected methods

### onAttachedToWindow

```
protected void onAttachedToWindow()
```

### onDetachedFromWindow

```
protected void onDetachedFromWindow()
```

### onMeasure

```
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
```