Google 致力于为黑人社区推动种族平等。查看具体举措

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 non-editable 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 when the MaterialAutoCompleteTextView is not editable, so that the first item of the popup is automatically focused. This simulates the behavior of the Spinner.

Summary

Inherited constants

From class android.widget.TextView
From class android.view.View

Inherited fields

From class android.view.View

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

From class androidx.appcompat.widget.AppCompatAutoCompleteTextView
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 androidx.core.view.TintableBackgroundView
From interface android.widget.Filter.FilterListener
From interface android.view.ViewTreeObserver.OnPreDrawListener
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

MaterialAutoCompleteTextView

MaterialAutoCompleteTextView (Context context)

Parameters
context Context

MaterialAutoCompleteTextView

MaterialAutoCompleteTextView (Context context, 
                AttributeSet attributeSet)

Parameters
context Context

attributeSet AttributeSet

MaterialAutoCompleteTextView

MaterialAutoCompleteTextView (Context context, 
                AttributeSet attributeSet, 
                int defStyleAttr)

Parameters
context Context

attributeSet AttributeSet

defStyleAttr int

Public methods

getHint

CharSequence getHint ()

Returns
CharSequence

setAdapter

void setAdapter (T adapter)

Parameters
adapter T

showDropDown

void showDropDown ()

Protected methods

onAttachedToWindow

void onAttachedToWindow ()

onMeasure

void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int