Android 12 Developer Preview is here! Try it out, and give us your feedback!

MaterialAutoCompleteTextView

public class MaterialAutoCompleteTextView
extends AppCompatAutoCompleteTextView

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.EditText
         ↳ android.widget.AutoCompleteTextView
           ↳ androidx.appcompat.widget.AppCompatAutoCompleteTextView
             ↳ com.google.android.material.textfield.MaterialAutoCompleteTextView


A special sub-class of 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 AutoCompleteTextView is not modal, so it does not grab accessibility focus. The 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 Spinner.

Summary

Inherited constants

Inherited fields

Public constructors

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

Public methods

CharSequence getHint()
<T extends ListAdapter & Filterable> void setAdapter(T adapter)
void showDropDown()

Protected methods

void onAttachedToWindow()
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited methods

Public constructors

MaterialAutoCompleteTextView

public MaterialAutoCompleteTextView (Context context)

Parameters
context Context

MaterialAutoCompleteTextView

public MaterialAutoCompleteTextView (Context context, 
                AttributeSet attributeSet)

Parameters
context Context

attributeSet AttributeSet

MaterialAutoCompleteTextView

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

Parameters
context Context

attributeSet AttributeSet

defStyleAttr int

Public methods

getHint

public CharSequence getHint ()

Returns
CharSequence

setAdapter

public void setAdapter (T adapter)

Parameters
adapter T

showDropDown

public void showDropDown ()

Protected methods

onAttachedToWindow

protected void onAttachedToWindow ()

onMeasure

protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int