public class AutoCompleteTextView extends EditText implements Filter.FilterListener
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
the threshold
.
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 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 the Text Fields guide.
Modifier and Type | Class and Description |
---|---|
static interface |
AutoCompleteTextView.OnDismissListener
Listener to respond to the AutoCompleteTextView's completion list being dismissed.
|
static interface |
AutoCompleteTextView.Validator
This interface is used to make sure that the text entered in this TextView complies to
a certain format.
|
TextView.BufferType, TextView.OnEditorActionListener, TextView.SavedState
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.DrawingCacheQuality, View.FindViewFlags, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.MeasureSpec, View.OnApplyWindowInsetsListener, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
ACCESSIBILITY_CURSOR_POSITION_UNDEFINED, ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, mAttributes, mBottom, mCachingFailed, mContext, mCurrentAnimation, mDebugViewAttributes, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NAVIGATION_BAR_TRANSIENT, NAVIGATION_BAR_TRANSLUCENT, NAVIGATION_BAR_TRANSPARENT, NAVIGATION_BAR_UNHIDE, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, PUBLIC_STATUS_BAR_VISIBILITY_MASK, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, sPreserveMarginParamsInLayoutParamConversion, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SEARCH, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_TRANSIENT, STATUS_BAR_TRANSLUCENT, STATUS_BAR_TRANSPARENT, STATUS_BAR_UNHIDE, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, SYSTEM_UI_TRANSPARENT, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
Constructor and Description |
---|
AutoCompleteTextView(Context context)
Constructs a new auto-complete text view with the given context's theme.
|
AutoCompleteTextView(Context context,
AttributeSet attrs)
Constructs a new auto-complete text view with the given context's theme
and the supplied attribute set.
|
AutoCompleteTextView(Context context,
AttributeSet attrs,
int defStyleAttr)
Constructs a new auto-complete text view with the given context's theme,
the supplied attribute set, and default style attribute.
|
AutoCompleteTextView(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Constructs a new auto-complete text view with the given context's theme,
the supplied attribute set, and default styles.
|
AutoCompleteTextView(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes,
Resources.Theme popupTheme)
Constructs a new auto-complete text view with the given context, the
supplied attribute set, default styles, and the theme against which the
completion popup should be inflated.
|
Modifier and Type | Method and Description |
---|---|
void |
clearListSelection()
Clear the list selection.
|
protected CharSequence |
convertSelectionToString(Object selectedItem)
Converts the selected item from the drop down list into a sequence
of character that can be used in the edit box.
|
void |
dismissDropDown()
Closes the drop down if present on screen.
|
boolean |
enoughToFilter()
Returns
true if the amount of text in the field meets
or exceeds the getThreshold() requirement. |
void |
ensureImeVisible(boolean visible)
Ensures that the drop down is not obscuring the IME.
|
ListAdapter |
getAdapter()
Returns a filterable list adapter used for auto completion.
|
CharSequence |
getCompletionHint()
Gets the optional hint text displayed at the bottom of the the matching list.
|
int |
getDropDownAnchor()
Returns the id for the view that the auto-complete drop down list is anchored to.
|
int |
getDropDownAnimationStyle()
Returns the animation style that is used when the drop-down list appears and disappears
|
Drawable |
getDropDownBackground()
Gets the background of the auto-complete drop-down list.
|
int |
getDropDownHeight()
Returns the current height for the auto-complete drop down list.
|
int |
getDropDownHorizontalOffset()
Gets the horizontal offset used for the auto-complete drop-down list.
|
int |
getDropDownVerticalOffset()
Gets the vertical offset used for the auto-complete drop-down list.
|
int |
getDropDownWidth()
Returns the current width for the auto-complete drop down list.
|
protected Filter |
getFilter()
Returns the Filter obtained from
Filterable.getFilter() ,
or null if setAdapter(T) was not called with
a Filterable. |
AdapterView.OnItemClickListener |
getItemClickListener()
Deprecated.
Use
getOnItemClickListener() intead |
AdapterView.OnItemSelectedListener |
getItemSelectedListener()
Deprecated.
Use
getOnItemSelectedListener() intead |
int |
getListSelection()
Get the position of the dropdown view selection, if there is one.
|
AdapterView.OnItemClickListener |
getOnItemClickListener()
Returns the listener that is notified whenever the user clicks an item
in the drop down list.
|
AdapterView.OnItemSelectedListener |
getOnItemSelectedListener()
Returns the listener that is notified whenever the user selects an
item in the drop down list.
|
int |
getThreshold()
Returns the number of characters the user must type before the drop
down list is shown.
|
AutoCompleteTextView.Validator |
getValidator()
Returns the Validator set with
setValidator(android.widget.AutoCompleteTextView.Validator) ,
or null if it was not set. |
boolean |
isDropDownAlwaysVisible() |
boolean |
isDropDownDismissedOnCompletion()
Checks whether the drop-down is dismissed when a suggestion is clicked.
|
boolean |
isInputMethodNotNeeded() |
boolean |
isPerformingCompletion()
Identifies whether the view is currently performing a text completion, so subclasses
can decide whether to respond to text changed events.
|
boolean |
isPopupShowing()
Indicates whether the popup menu is showing.
|
protected void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
void |
onCommitCompletion(CompletionInfo completion)
Called by the framework in response to a text completion from
the current input method, provided by it calling
InputConnection.commitCompletion() . |
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window.
|
protected void |
onDisplayHint(int hint)
Gives this view a hint about whether is displayed or not.
|
void |
onFilterComplete(int count)
Notifies the end of a filtering operation.
|
protected void |
onFocusChanged(boolean focused,
int direction,
Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes.
|
boolean |
onKeyDown(int keyCode,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyDown() : perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable. |
boolean |
onKeyPreIme(int keyCode,
KeyEvent event)
Handle a key event before it is processed by any input method
associated with the view hierarchy.
|
boolean |
onKeyUp(int keyCode,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyUp() : perform clicking of the view
when KeyEvent.KEYCODE_DPAD_CENTER , KeyEvent.KEYCODE_ENTER
or KeyEvent.KEYCODE_SPACE is released. |
void |
onWindowFocusChanged(boolean hasWindowFocus)
Called when the window containing this view gains or loses focus.
|
void |
performCompletion()
Performs the text completion by converting the selected item from
the drop down list into a string, replacing the text box's content with
this string and finally dismissing the drop down menu.
|
protected void |
performFiltering(CharSequence text,
int keyCode)
Starts filtering the content of the drop down list.
|
void |
performValidation()
If a validator was set on this view and the current string is not valid,
ask the validator to fix it.
|
protected void |
replaceText(CharSequence text)
Performs the text completion by replacing the current text by the
selected item.
|
<T extends ListAdapter & Filterable> |
setAdapter(T adapter)
Changes the list of data used for auto completion.
|
void |
setCompletionHint(CharSequence hint)
Sets the optional hint text that is displayed at the bottom of the
the matching list.
|
void |
setDropDownAlwaysVisible(boolean dropDownAlwaysVisible)
Sets whether the drop-down should remain visible as long as there is there is
enoughToFilter() . |
void |
setDropDownAnchor(int id)
Sets the view to which the auto-complete drop down list should anchor.
|
void |
setDropDownAnimationStyle(int animationStyle)
Sets the animation style of the auto-complete drop-down list.
|
void |
setDropDownBackgroundDrawable(Drawable d)
Sets the background of the auto-complete drop-down list.
|
void |
setDropDownBackgroundResource(int id)
Sets the background of the auto-complete drop-down list.
|
void |
setDropDownDismissedOnCompletion(boolean dropDownDismissedOnCompletion)
Sets whether the drop-down is dismissed when a suggestion is clicked.
|
void |
setDropDownHeight(int height)
Sets the current height for the auto-complete drop down list.
|
void |
setDropDownHorizontalOffset(int offset)
Sets the horizontal offset used for the auto-complete drop-down list.
|
void |
setDropDownVerticalOffset(int offset)
Sets the vertical offset used for the auto-complete drop-down list.
|
void |
setDropDownWidth(int width)
Sets the current width for the auto-complete drop down list.
|
void |
setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch)
Forces outside touches to be ignored.
|
protected boolean |
setFrame(int l,
int t,
int r,
int b)
Assign a size and position to this view.
|
void |
setListSelection(int position)
Set the position of the dropdown view selection.
|
void |
setOnClickListener(View.OnClickListener listener)
Register a callback to be invoked when this view is clicked.
|
void |
setOnDismissListener(AutoCompleteTextView.OnDismissListener dismissListener)
Set a listener that will be invoked whenever the AutoCompleteTextView's
list of completions is dismissed.
|
void |
setOnItemClickListener(AdapterView.OnItemClickListener l)
Sets the listener that will be notified when the user clicks an item
in the drop down list.
|
void |
setOnItemSelectedListener(AdapterView.OnItemSelectedListener l)
Sets the listener that will be notified when the user selects an item
in the drop down list.
|
void |
setText(CharSequence text,
boolean filter)
Like
TextView.setText(CharSequence) , except that it can disable filtering. |
void |
setThreshold(int threshold)
Specifies the minimum number of characters the user has to type in the
edit box before the drop down list is shown.
|
void |
setValidator(AutoCompleteTextView.Validator validator)
Sets the validator used to perform text validation.
|
void |
showDropDown()
Displays the drop down on screen.
|
void |
showDropDownAfterLayout()
Issues a runnable to show the dropdown as soon as possible.
|
extendSelection, getAccessibilityClassName, getDefaultEditable, getDefaultMovementMethod, getFreezesText, getText, onInitializeAccessibilityNodeInfoInternal, selectAll, setEllipsize, setSelection, setSelection, setText
addTextChangedListener, append, append, beginBatchEdit, bringPointIntoView, cancelLongPress, clearComposingText, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollRange, debug, deleteText_internal, didTouchFocusSelect, drawableHotspotChanged, drawableStateChanged, encodeProperties, endBatchEdit, extractText, findViewsWithText, getAccessibilitySelectionEnd, getAccessibilitySelectionStart, getAutoLinkMask, getBaseline, getBottomPaddingOffset, getBreakStrategy, getCompoundDrawablePadding, getCompoundDrawables, getCompoundDrawablesRelative, getCompoundDrawableTintList, getCompoundDrawableTintMode, getCompoundPaddingBottom, getCompoundPaddingEnd, getCompoundPaddingLeft, getCompoundPaddingRight, getCompoundPaddingStart, getCompoundPaddingTop, getCurrentHintTextColor, getCurrentTextColor, getCustomInsertionActionModeCallback, getCustomSelectionActionModeCallback, getEditableText, getEditorForTesting, getEllipsize, getError, getExtendedPaddingBottom, getExtendedPaddingTop, getFadeHeight, getFadeTop, getFilters, getFocusedRect, getFontFeatureSettings, getGravity, getHighlightColor, getHint, getHintTextColors, getHorizontallyScrolling, getHorizontalOffsetForDrawables, getHyphenationFrequency, getImeActionId, getImeActionLabel, getImeHintLocales, getImeOptions, getIncludeFontPadding, getInputExtras, getInputType, getIterableTextForAccessibility, getIteratorForGranularity, getKeyListener, getLayout, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLetterSpacing, getLineBounds, getLineCount, getLineHeight, getLineSpacingExtra, getLineSpacingMultiplier, getLinksClickable, getLinkTextColors, getMarqueeRepeatLimit, getMaxEms, getMaxHeight, getMaxLines, getMaxWidth, getMinEms, getMinHeight, getMinLines, getMinWidth, getMovementMethod, getOffsetForPosition, getPaint, getPaintFlags, getPrivateImeOptions, getRightFadingEdgeStrength, getRightPaddingOffset, getScaledTextSize, getSelectionEnd, getSelectionStart, getShadowColor, getShadowDx, getShadowDy, getShadowRadius, getShowSoftInputOnFocus, getSpellCheckerLocale, getTextColor, getTextColors, getTextColors, getTextDirectionHeuristic, getTextLocale, getTextLocales, getTextScaleX, getTextServicesLocale, getTextSize, getTopPaddingOffset, getTotalPaddingBottom, getTotalPaddingEnd, getTotalPaddingLeft, getTotalPaddingRight, getTotalPaddingStart, getTotalPaddingTop, getTransformationMethod, getTypeface, getTypefaceStyle, getUndoManager, getUrls, getWordIterator, handleBackInTextActionModeIfNeeded, hasOverlappingRendering, hasSelection, hideErrorIfUnchanged, invalidateDrawable, isAccessibilitySelectionExtendable, isCursorVisible, isInExtractedMode, isInputMethodTarget, isPaddingOffsetRequired, isSuggestionsEnabled, isTextSelectable, jumpDrawablesToCurrentState, length, makeNewLayout, makeSingleLayout, moveCursorToVisibleOffset, onActivityResult, onBeginBatchEdit, onCheckIsTextEditor, onCommitCorrection, onConfigurationChanged, onCreateContextMenu, onCreateDrawableState, onCreateInputConnection, onDetachedFromWindowInternal, onDragEvent, onDraw, onEditorAction, onEndBatchEdit, onGenericMotionEvent, onInitializeAccessibilityEventInternal, onKeyMultiple, onKeyShortcut, onLayout, onMeasure, onPopulateAccessibilityEventInternal, onPreDraw, onPrivateIMECommand, onProvideStructure, onResolveDrawables, onResolvePointerIcon, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSelectionChanged, onTextChanged, onTextContextMenuItem, onTouchEvent, onTrackballEvent, onVisibilityChanged, performAccessibilityActionInternal, performLongClick, preloadFontCache, removeTextChangedListener, replaceText_internal, resetErrorChangedFlag, resetResolvedDrawables, sendAccessibilityEventInternal, setAccessibilitySelection, setAllCaps, setAutoLinkMask, setBreakStrategy, setCompoundDrawablePadding, setCompoundDrawables, setCompoundDrawablesRelative, setCompoundDrawablesRelativeWithIntrinsicBounds, setCompoundDrawablesRelativeWithIntrinsicBounds, setCompoundDrawablesWithIntrinsicBounds, setCompoundDrawablesWithIntrinsicBounds, setCompoundDrawableTintList, setCompoundDrawableTintMode, setCursorPosition_internal, setCursorVisible, setCustomInsertionActionModeCallback, setCustomSelectionActionModeCallback, setEditableFactory, setElegantTextHeight, setEms, setEnabled, setError, setError, setExtractedText, setExtracting, setFilters, setFontFeatureSettings, setFreezesText, setGravity, setHeight, setHighlightColor, setHint, setHint, setHintTextColor, setHintTextColor, setHorizontallyScrolling, setHyphenationFrequency, setImeActionLabel, setImeHintLocales, setImeOptions, setIncludeFontPadding, setInputExtras, setInputType, setKeyListener, setLetterSpacing, setLines, setLineSpacing, setLinksClickable, setLinkTextColor, setLinkTextColor, setMarqueeRepeatLimit, setMaxEms, setMaxHeight, setMaxLines, setMaxWidth, setMinEms, setMinHeight, setMinLines, setMinWidth, setMovementMethod, setOnEditorActionListener, setPadding, setPaddingRelative, setPaintFlags, setPrivateImeOptions, setRawInputType, setScroller, setSelectAllOnFocus, setSelected, setShadowLayer, setShowSoftInputOnFocus, setSingleLine, setSingleLine, setSpan_internal, setSpannableFactory, setText, setText, setText, setText, setTextAppearance, setTextAppearance, setTextColor, setTextColor, setTextIsSelectable, setTextKeepState, setTextKeepState, setTextLocale, setTextLocales, setTextScaleX, setTextSize, setTextSize, setTransformationMethod, setTypeface, setTypeface, setUndoManager, setWidth, showContextMenu, showContextMenu, stopTextActionMode, verifyDrawable, viewClicked
addChildrenForAccessibility, addFocusables, addFocusables, addFrameMetricsListener, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelPendingInputEvents, canHaveDisplayList, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, captureTransitioningViews, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, clearFocus, combineMeasuredStates, computeFitSystemWindows, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeOpaqueFlags, computeSystemWindowInsets, computeVerticalScrollOffset, createAccessibilityNodeInfo, createAccessibilityNodeInfoInternal, createContextMenu, createSnapshot, damageInParent, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchActivityResult, dispatchApplyWindowInsets, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchGetDisplayList, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, dispatchPopulateAccessibilityEventInternal, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, draw, encode, findFocus, findNamedViews, findViewByAccessibilityIdTraversal, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewByPredicateTraversal, findViewTraversal, findViewWithTag, findViewWithTagTraversal, fitsSystemWindows, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, gatherTransparentRegion, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBottom, getBottomFadingEdgeStrength, getBoundsOnScreen, getBoundsOnScreen, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getHotspotBounds, getId, getImportantForAccessibility, getInverseMatrix, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOutlineProvider, getOutsets, getOverlay, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRevealOnFocusHint, getRight, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowDisplayFrame, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, handleScrollBarDragging, hasFocus, hasFocusable, hasHoveredChild, hasNestedScrollingParent, hasOnClickListeners, hasOpaqueScrollbars, hasShadow, hasTransientState, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeFadingEdgeInternal, initializeScrollbars, initializeScrollbarsInternal, internalSetPadding, invalidate, invalidate, invalidate, invalidateOutline, invalidateParentCaches, invalidateParentIfNeeded, invalidateParentIfNeededAndWasQuickRejected, isAccessibilityFocused, isActionableForAccessibility, isActivated, isAssistBlocked, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isForegroundInsidePadding, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInScrollingContainer, isInTouchMode, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutModeOptical, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, layout, makeOptionalFitsSystemWindows, measure, mergeDrawableStates, notifySubtreeAccessibilityStateChangedIfNeeded, notifyViewAccessibilityStateChangedIfNeeded, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCloseSystemDialogs, onDrawForeground, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusLost, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyLongPress, onOverScrolled, onPopulateAccessibilityEvent, onProvideVirtualStructure, onRenderNodeDetached, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onVisibilityAggregated, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeFrameMetricsListener, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestKeyboardShortcuts, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resetPaddingToInitialValues, resetResolvedLayoutDirection, resetResolvedPadding, resetResolvedTextAlignment, resetResolvedTextDirection, resetRtlProperties, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveSize, resolveSizeAndState, resolveTextAlignment, resolveTextDirection, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, sendAccessibilityEventUncheckedInternal, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAssistBlocked, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOpticalInsets, setOutlineProvider, setOverScrollMode, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealClip, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, startActionMode, startActionMode, startActivityForResult, startAnimation, startDrag, startDragAndDrop, startMovingTask, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDisplayListIfDirty, updateDragShadow, willNotCacheDrawing, willNotDraw
public AutoCompleteTextView(Context context)
context
- The Context the view is running in, through which it can
access the current theme, resources, etc.public AutoCompleteTextView(Context context, AttributeSet attrs)
context
- The Context the view is running in, through which it can
access the current theme, resources, etc.attrs
- The attributes of the XML tag that is inflating the view.public AutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr)
context
- The Context the view is running in, through which it can
access the current theme, resources, etc.attrs
- The attributes of the XML tag that is inflating the view.defStyleAttr
- An attribute in the current theme that contains a
reference to a style resource that supplies default
values for the view. Can be 0 to not look for
defaults.public AutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
context
- The Context the view is running in, through which it can
access the current theme, resources, etc.attrs
- The attributes of the XML tag that is inflating the view.defStyleAttr
- An attribute in the current theme that contains a
reference to a style resource that supplies default
values for the view. Can be 0 to not look for
defaults.defStyleRes
- A resource identifier of a style resource that
supplies default values for the view, used only if
defStyleAttr is 0 or can not be found in the theme.
Can be 0 to not look for defaults.public AutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes, Resources.Theme popupTheme)
context
- The context against which the view is inflated, which
provides access to the current theme, resources, etc.attrs
- The attributes of the XML tag that is inflating the view.defStyleAttr
- An attribute in the current theme that contains a
reference to a style resource that supplies default
values for the view. Can be 0 to not look for
defaults.defStyleRes
- A resource identifier of a style resource that
supplies default values for the view, used only if
defStyleAttr is 0 or can not be found in the theme.
Can be 0 to not look for defaults.popupTheme
- The theme against which the completion popup window
should be inflated. May be null
to use the
view theme. If set, this will override any value
specified by
android.R.styleable#AutoCompleteTextView_popupTheme
.public void setOnClickListener(View.OnClickListener listener)
View
setOnClickListener
in class View
listener
- The callback that will runView.setClickable(boolean)
public void setCompletionHint(CharSequence hint)
Sets the optional hint text that is displayed at the bottom of the the matching list. This can be used as a cue to the user on how to best use the list, or to provide extra information.
hint
- the text to be displayed to the usergetCompletionHint()
public CharSequence getCompletionHint()
setCompletionHint(CharSequence)
public int getDropDownWidth()
Returns the current width for the auto-complete drop down list. This can
be a fixed width, or ViewGroup.LayoutParams#MATCH_PARENT
to fill the screen, or
ViewGroup.LayoutParams#WRAP_CONTENT
to fit the width of its anchor view.
public void setDropDownWidth(int width)
Sets the current width for the auto-complete drop down list. This can
be a fixed width, or ViewGroup.LayoutParams#MATCH_PARENT
to fill the screen, or
ViewGroup.LayoutParams#WRAP_CONTENT
to fit the width of its anchor view.
width
- the width to usepublic int getDropDownHeight()
Returns the current height for the auto-complete drop down list. This can
be a fixed height, or ViewGroup.LayoutParams#MATCH_PARENT
to fill
the screen, or ViewGroup.LayoutParams#WRAP_CONTENT
to fit the height
of the drop down's content.
public void setDropDownHeight(int height)
Sets the current height for the auto-complete drop down list. This can
be a fixed height, or ViewGroup.LayoutParams#MATCH_PARENT
to fill
the screen, or ViewGroup.LayoutParams#WRAP_CONTENT
to fit the height
of the drop down's content.
height
- the height to usepublic int getDropDownAnchor()
Returns the id for the view that the auto-complete drop down list is anchored to.
View.NO_ID
if none specifiedpublic void setDropDownAnchor(int id)
Sets the view to which the auto-complete drop down list should anchor. The view corresponding to this id will not be loaded until the next time it is needed to avoid loading a view which is not yet instantiated.
id
- the id to anchor the drop down list view topublic Drawable getDropDownBackground()
Gets the background of the auto-complete drop-down list.
public void setDropDownBackgroundDrawable(Drawable d)
Sets the background of the auto-complete drop-down list.
d
- the drawable to set as the backgroundpublic void setDropDownBackgroundResource(@DrawableRes int id)
Sets the background of the auto-complete drop-down list.
id
- the id of the drawable to set as the backgroundpublic void setDropDownVerticalOffset(int offset)
Sets the vertical offset used for the auto-complete drop-down list.
offset
- the vertical offsetpublic int getDropDownVerticalOffset()
Gets the vertical offset used for the auto-complete drop-down list.
public void setDropDownHorizontalOffset(int offset)
Sets the horizontal offset used for the auto-complete drop-down list.
offset
- the horizontal offsetpublic int getDropDownHorizontalOffset()
Gets the horizontal offset used for the auto-complete drop-down list.
public void setDropDownAnimationStyle(int animationStyle)
Sets the animation style of the auto-complete drop-down list.
If the drop-down is showing, calling this method will take effect only the next time the drop-down is shown.
animationStyle
- animation style to use when the drop-down appears
and disappears. Set to -1 for the default animation, 0 for no
animation, or a resource identifier for an explicit animation.public int getDropDownAnimationStyle()
Returns the animation style that is used when the drop-down list appears and disappears
public boolean isDropDownAlwaysVisible()
enoughToFilter()
public void setDropDownAlwaysVisible(boolean dropDownAlwaysVisible)
enoughToFilter()
. This is useful if an unknown number of results are expected
to show up in the adapter sometime in the future.
The drop-down will occupy the entire screen below getDropDownAnchor()
regardless
of the size or content of the list. getDropDownBackground()
will fill any space
that is not used by the list.dropDownAlwaysVisible
- Whether to keep the drop-down visible.public boolean isDropDownDismissedOnCompletion()
public void setDropDownDismissedOnCompletion(boolean dropDownDismissedOnCompletion)
dropDownDismissedOnCompletion
- Whether to dismiss the drop-down.public int getThreshold()
Returns the number of characters the user must type before the drop down list is shown.
setThreshold(int)
public void setThreshold(int threshold)
Specifies the minimum number of characters the user has to type in the edit box before the drop down list is shown.
When threshold
is less than or equals 0, a threshold of
1 is applied.
threshold
- the number of characters to type before the drop down
is showngetThreshold()
public void setOnItemClickListener(AdapterView.OnItemClickListener l)
Sets the listener that will be notified when the user clicks an item in the drop down list.
l
- the item click listenerpublic void setOnItemSelectedListener(AdapterView.OnItemSelectedListener l)
Sets the listener that will be notified when the user selects an item in the drop down list.
l
- the item selected listener@Deprecated public AdapterView.OnItemClickListener getItemClickListener()
getOnItemClickListener()
inteadReturns the listener that is notified whenever the user clicks an item in the drop down list.
@Deprecated public AdapterView.OnItemSelectedListener getItemSelectedListener()
getOnItemSelectedListener()
inteadReturns the listener that is notified whenever the user selects an item in the drop down list.
public AdapterView.OnItemClickListener getOnItemClickListener()
Returns the listener that is notified whenever the user clicks an item in the drop down list.
public AdapterView.OnItemSelectedListener getOnItemSelectedListener()
Returns the listener that is notified whenever the user selects an item in the drop down list.
public void setOnDismissListener(AutoCompleteTextView.OnDismissListener dismissListener)
dismissListener
- Listener to invoke when completions are dismissedpublic ListAdapter getAdapter()
Returns a filterable list adapter used for auto completion.
public <T extends ListAdapter & Filterable> void setAdapter(T adapter)
Changes the list of data used for auto completion. The provided list must be a filterable list adapter.
The caller is still responsible for managing any resources used by the adapter.
Notably, when the AutoCompleteTextView is closed or released, the adapter is not notified.
A common case is the use of CursorAdapter
, which
contains a Cursor
that must be closed. This can be done
automatically (see
startManagingCursor()
),
or by manually closing the cursor when the AutoCompleteTextView is dismissed.
adapter
- the adapter holding the auto completion datagetAdapter()
,
Filterable
,
ListAdapter
public boolean onKeyPreIme(int keyCode, KeyEvent event)
View
onKeyPreIme
in class TextView
keyCode
- The value in event.getKeyCode().event
- Description of the key event.public boolean onKeyUp(int keyCode, KeyEvent event)
View
KeyEvent.Callback.onKeyUp()
: perform clicking of the view
when KeyEvent.KEYCODE_DPAD_CENTER
, KeyEvent.KEYCODE_ENTER
or KeyEvent.KEYCODE_SPACE
is released.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyUp
in interface KeyEvent.Callback
onKeyUp
in class TextView
keyCode
- A key code that represents the button pressed, from
KeyEvent
.event
- The KeyEvent object that defines the button action.public boolean onKeyDown(int keyCode, KeyEvent event)
View
KeyEvent.Callback.onKeyDown()
: perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER
or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyDown
in interface KeyEvent.Callback
onKeyDown
in class TextView
keyCode
- a key code that represents the button pressed, from
KeyEvent
event
- the KeyEvent object that defines the button actionpublic boolean enoughToFilter()
true
if the amount of text in the field meets
or exceeds the getThreshold()
requirement. You can override
this to impose a different standard for when filtering will be
triggered.public boolean isPopupShowing()
Indicates whether the popup menu is showing.
protected CharSequence convertSelectionToString(Object selectedItem)
Converts the selected item from the drop down list into a sequence of character that can be used in the edit box.
selectedItem
- the item selected by the user for completionpublic void clearListSelection()
Clear the list selection. This may only be temporary, as user input will often bring it back.
public void setListSelection(int position)
position
- The position to move the selector to.public int getListSelection()
ListView.INVALID_POSITION
if there is no dropdown or if
there is no selection.ListView.INVALID_POSITION
if not.AdapterView.getSelectedItemPosition()
protected void performFiltering(CharSequence text, int keyCode)
Starts filtering the content of the drop down list. The filtering
pattern is the content of the edit box. Subclasses should override this
method to filter with a different pattern, for instance a substring of
text
.
text
- the filtering patternkeyCode
- the last character inserted in the edit box; beware that
this will be null when text is being added through a soft input method.public void performCompletion()
Performs the text completion by converting the selected item from the drop down list into a string, replacing the text box's content with this string and finally dismissing the drop down menu.
public void onCommitCompletion(CompletionInfo completion)
TextView
InputConnection.commitCompletion()
. The default implementation does
nothing; text views that are supporting auto-completion should override
this to do their desired behavior.onCommitCompletion
in class TextView
completion
- The auto complete text the user has selected.public boolean isPerformingCompletion()
public void setText(CharSequence text, boolean filter)
TextView.setText(CharSequence)
, except that it can disable filtering.filter
- If false
, no filtering will be performed
as a result of this call.protected void replaceText(CharSequence text)
Performs the text completion by replacing the current text by the selected item. Subclasses should override this method to avoid replacing the whole content of the edit box.
text
- the selected suggestion in the drop down listpublic void onFilterComplete(int count)
Notifies the end of a filtering operation.
onFilterComplete
in interface Filter.FilterListener
count
- the number of values computed by the filterpublic void onWindowFocusChanged(boolean hasWindowFocus)
View
onWindowFocusChanged
in class TextView
hasWindowFocus
- True if the window containing this view now has
focus, false otherwise.protected void onDisplayHint(int hint)
View
onDisplayHint
in class View
hint
- A hint about whether or not this view is displayed:
View.VISIBLE
or View.INVISIBLE
.protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
View
onFocusChanged
in class TextView
focused
- True if the View has focus; false otherwise.direction
- The direction focus has moved when requestFocus()
is called to give this view focus. Values are
View.FOCUS_UP
, View.FOCUS_DOWN
, View.FOCUS_LEFT
,
View.FOCUS_RIGHT
, View.FOCUS_FORWARD
, or View.FOCUS_BACKWARD
.
It may not always apply, in which case use the default.previouslyFocusedRect
- The rectangle, in this view's coordinate
system, of the previously focused view. If applicable, this will be
passed in as finer grained information about where the focus is coming
from (in addition to direction). Will be null
otherwise.protected void onAttachedToWindow()
View
View.onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after View.onMeasure(int, int)
.onAttachedToWindow
in class TextView
View.onDetachedFromWindow()
protected void onDetachedFromWindow()
View
onDetachedFromWindow
in class View
View.onAttachedToWindow()
public void dismissDropDown()
Closes the drop down if present on screen.
protected boolean setFrame(int l, int t, int r, int b)
View
public void showDropDownAfterLayout()
public void ensureImeVisible(boolean visible)
visible
- whether the ime should be in front. If false, the ime is pushed to
the background.public boolean isInputMethodNotNeeded()
public void showDropDown()
Displays the drop down on screen.
public void setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch)
isDropDownAlwaysVisible()
is
false, we allow outside touch to dismiss the dropdown. If this is set to true, then we
ignore outside touch even when the drop down is not set to always visible.public void setValidator(AutoCompleteTextView.Validator validator)
validator
- The validator used to validate the text entered in this widget.getValidator()
,
performValidation()
public AutoCompleteTextView.Validator getValidator()
setValidator(android.widget.AutoCompleteTextView.Validator)
,
or null
if it was not set.public void performValidation()
protected Filter getFilter()
Filterable.getFilter()
,
or null
if setAdapter(T)
was not called with
a Filterable.