AutoCompleteTextView自动完成文本框是Android中一个空间,继承于TextView。
在Android Developer中的数据属性和方法如下:
Summary
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
AutoCompleteTextView.OnDismissListener | Listener to respond to the AutoCompleteTextView's completion list being dismissed. | |||||||||
|
AutoCompleteTextView.Validator | This interface is used to make sure that the text entered in this TextView complies to a certain format. |
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|||||||||
android:completionHint | setCompletionHint(CharSequence) | Defines the hint displayed in the drop down menu. | |||||||||
android:completionHintView | Defines the hint view displayed in the drop down menu. | ||||||||||
android:completionThreshold | setThreshold(int) | Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu. | |||||||||
android:dropDownAnchor | setDropDownAnchor(int) | View to anchor the auto-complete dropdown to. | |||||||||
android:dropDownHeight | setDropDownHeight(int) | Specifies the basic height of the dropdown. | |||||||||
android:dropDownHorizontalOffset | Amount of pixels by which the drop down should be offset horizontally. | ||||||||||
android:dropDownSelector | Selector in a drop down list. | ||||||||||
android:dropDownVerticalOffset | Amount of pixels by which the drop down should be offset vertically. | ||||||||||
android:dropDownWidth | setDropDownWidth(int) | Specifies the basic width of the dropdown. | |||||||||
android:popupBackground | setDropDownBackgroundResource(int) |
[Expand]Inherited XML Attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class android.widget.TextView
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class android.view.View
|
[Expand]Inherited Constants | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class android.view.View
|
[Expand]Inherited Fields | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class android.view.View
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||
|
|
||||||||||
|
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Clear the list selection. |
||||||||||
|
Closes the drop down if present on screen. |
||||||||||
|
true if the amount of text in the field meets or exceeds thegetThreshold() requirement.
|
||||||||||
|
Returns a filterable list adapter used for auto completion. |
||||||||||
|
|
||||||||||
|
Returns the id for the view that the auto-complete drop down list is anchored to. |
||||||||||
|
Gets the background of the auto-complete drop-down list. |
||||||||||
|
Returns the current height for the auto-complete drop down list. |
||||||||||
|
Gets the horizontal offset used for the auto-complete drop-down list. |
||||||||||
|
Gets the vertical offset used for the auto-complete drop-down list. |
||||||||||
|
Returns the current width for the auto-complete drop down list. |
||||||||||
|
intead
|
||||||||||
|
intead
|
||||||||||
|
|
||||||||||
|
Returns the listener that is notified whenever the user clicks an item in the drop down list. |
||||||||||
|
Returns the listener that is notified whenever the user selects an item in the drop down list. |
||||||||||
|
Returns the number of characters the user must type before the drop down list is shown. |
||||||||||
|
setValidator(AutoCompleteTextView.Validator) , or null if it was not set.
|
||||||||||
|
|
||||||||||
|
Indicates whether the popup menu is showing. |
||||||||||
|
InputConnection.commitCompletion() .
|
||||||||||
|
Notifies the end of a filtering operation. |
||||||||||
|
KeyEvent.Callback.onKeyDown() : perform press of the view when KEYCODE_DPAD_CENTER orKEYCODE_ENTER is released, if the view is enabled and clickable.
|
||||||||||
|
|
||||||||||
|
KeyEvent.Callback.onKeyUp() : perform clicking of the view when KEYCODE_DPAD_CENTER orKEYCODE_ENTER is released.
|
||||||||||
|
|
||||||||||
|
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. |
||||||||||
|
|
||||||||||
|
Changes the list of data used for auto completion. |
||||||||||
|
Sets the optional hint text that is displayed at the bottom of the the matching list. |
||||||||||
|
Sets the view to which the auto-complete drop down list should anchor. |
||||||||||
|
Sets the background of the auto-complete drop-down list. |
||||||||||
|
Sets the background of the auto-complete drop-down list. |
||||||||||
|
Sets the current height for the auto-complete drop down list. |
||||||||||
|
Sets the horizontal offset used for the auto-complete drop-down list. |
||||||||||
|
Sets the vertical offset used for the auto-complete drop-down list. |
||||||||||
|
Sets the current width for the auto-complete drop down list. |
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
Sets the listener that will be notified when the user clicks an item in the drop down list. |
||||||||||
|
Sets the listener that will be notified when the user selects an item in the drop down list. |
||||||||||
|
setText(CharSequence) , except that it can disable filtering.
|
||||||||||
|
Specifies the minimum number of characters the user has to type in the edit box before the drop down list is shown. |
||||||||||
|
|
||||||||||
|
Displays the drop down on screen. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Converts the selected item from the drop down list into a sequence of character that can be used in the edit box. |
||||||||||
|
getFilter() , ornull if setAdapter(T) was not called with a Filterable.
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
Starts filtering the content of the drop down list. |
||||||||||
|
Performs the text completion by replacing the current text by the selected item. |
||||||||||
|
|
[Expand]Inherited Methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class android.widget.EditText
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class android.widget.TextView
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class android.view.View
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class java.lang.Object
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface android.graphics.drawable.Drawable.Callback
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface android.view.KeyEvent.Callback
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface android.view.ViewTreeObserver.OnPreDrawListener
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface android.view.accessibility.AccessibilityEventSource
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface android.widget.Filter.FilterListener
|
XML Attributes
android:completionHint
Defines the hint displayed in the drop down menu.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form "@[package:]type:name
") or theme attribute (in the form "?[package:][type:]name
") containing a value of this type.
This corresponds to the global attribute resource symbol completionHint
.
Related Methods
android:completionHintView
Defines the hint view displayed in the drop down menu.
Must be a reference to another resource, in the form "@[+][package:]type:name
" or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol completionHintView
.
Related Methods
android:completionThreshold
Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu.
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form "@[package:]type:name
") or theme attribute (in the form "?[package:][type:]name
") containing a value of this type.
This corresponds to the global attribute resource symbol completionThreshold
.
Related Methods
android:dropDownAnchor
View to anchor the auto-complete dropdown to. If not specified, the text view itself is used.
Must be a reference to another resource, in the form "@[+][package:]type:name
" or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute resource symbol dropDownAnchor
.
Related Methods
android:dropDownHeight
Specifies the basic height of the dropdown. Its value may be a dimension (such as "12dip") for a constant height, fill_parent or match_parent to fill the height of the screen, or wrap_content to match the height of the content of the drop down.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp
". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).
This may also be a reference to a resource (in the form "@[package:]type:name
") or theme attribute (in the form "?[package:][type:]name
") containing a value of this type.
May be one of the following constant values.
Constant | Value | Description |
---|---|---|
fill_parent |
-1 | The dropdown should fit the height of the screen. This constant is deprecated starting from API Level 8 and is replaced bymatch_parent . |
match_parent |
-1 | The dropdown should fit the height of the screen. Introduced in API Level 8. |
wrap_content |
-2 | The dropdown should fit the height of the content. |
This corresponds to the global attribute resource symbol dropDownHeight
.
Related Methods
android:dropDownHorizontalOffset
Amount of pixels by which the drop down should be offset horizontally.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).
This may also be a reference to a resource (in the form "@[package:]type:name
") or theme attribute (in the form "?[package:][type:]name
") containing a value of this type.
This corresponds to the global attribute resource symbol dropDownHorizontalOffset
.
Related Methods
android:dropDownSelector
Selector in a drop down list.
May be a reference to another resource, in the form "@[+][package:]type:name
" or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
", "#rrggbb
", or "#aarrggbb
".
This corresponds to the global attribute resource symbol dropDownSelector
.
Related Methods
android:dropDownVerticalOffset
Amount of pixels by which the drop down should be offset vertically.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp
". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).
This may also be a reference to a resource (in the form "@[package:]type:name
") or theme attribute (in the form "?[package:][type:]name
") containing a value of this type.
This corresponds to the global attribute resource symbol dropDownVerticalOffset
.
Related Methods
android:dropDownWidth
Specifies the basic width of the dropdown. Its value may be a dimension (such as "12dip") for a constant width, fill_parent or match_parent to match the width of the screen, or wrap_content to match the width of the anchored view.
May be a dimension value, which is a floating point number appended with a unit such as "14.5sp
". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).
This may also be a reference to a resource (in the form "@[package:]type:name
") or theme attribute (in the form "?[package:][type:]name
") containing a value of this type.
May be one of the following constant values.
Constant | Value | Description |
---|---|---|
fill_parent |
-1 | The dropdown should fill the width of the screen. This constant is deprecated starting from API Level 8 and is replaced bymatch_parent . |
match_parent |
-1 | The dropdown should fit the width of the screen. Introduced in API Level 8. |
wrap_content |
-2 | The dropdown should fit the width of its anchor. |
This corresponds to the global attribute resource symbol dropDownWidth
.
Related Methods
android:popupBackground
Related Methods
Public Constructors
public AutoCompleteTextView(Context context)
Added in API level 1public AutoCompleteTextView(Context context,AttributeSet attrs)
Added in API level 1public AutoCompleteTextView(Context context,AttributeSet attrs, int defStyle)
Added in API level 1Public Methods
public void clearListSelection()
Added in API level 3Clear the list selection. This may only be temporary, as user input will often bring it back.
public void dismissDropDown()
Added in API level 1Closes the drop down if present on screen.
public boolean enoughToFilter()
Added in API level 1Returns true
if the amount of text in the field meets or exceeds thegetThreshold()
requirement. You can override this to impose a different standard for when filtering will be triggered.
public ListAdapter getAdapter ()
Added in API level 1Returns a filterable list adapter used for auto completion.
Returns
- a data adapter used for auto completion
public CharSequence getCompletionHint ()
Added in API level 16Gets the optional hint text displayed at the bottom of the the matching list.
Related XML Attributes
Returns
- The hint text, if any
See Also
public int getDropDownAnchor()
Added in API level 3Returns the id for the view that the auto-complete drop down list is anchored to.
Related XML Attributes
Returns
- the view's id, or
NO_ID
if none specified
public Drawable getDropDownBackground ()
Added in API level 5Gets the background of the auto-complete drop-down list.
Related XML Attributes
Returns
- the background drawable
public int getDropDownHeight()
Added in API level 4Returns the current height for the auto-complete drop down list. This can be a fixed height, orMATCH_PARENT
to fill the screen, orWRAP_CONTENT
to fit the height of the drop down's content.
Related XML Attributes
Returns
- the height for the drop down list
public int getDropDownHorizontalOffset()
Added in API level 5Gets the horizontal offset used for the auto-complete drop-down list.
Returns
- the horizontal offset
public int getDropDownVerticalOffset()
Added in API level 5Gets the vertical offset used for the auto-complete drop-down list.
Returns
- the vertical offset
public int getDropDownWidth()
Added in API level 3Returns the current width for the auto-complete drop down list. This can be a fixed width, orMATCH_PARENT
to fill the screen, orWRAP_CONTENT
to fit the width of its anchor view.
Related XML Attributes
Returns
- the width for the drop down list
public AdapterView.OnItemClickListener getItemClickListener()
Added in API level 1This method was deprecated in API level 3.
Use getOnItemClickListener()
intead
Returns the listener that is notified whenever the user clicks an item in the drop down list.
Returns
- the item click listener
public AdapterView.OnItemSelectedListener getItemSelectedListener()
Added in API level 1This method was deprecated in API level 3.
Use getOnItemSelectedListener()
intead
Returns the listener that is notified whenever the user selects an item in the drop down list.
Returns
- the item selected listener
public int getListSelection()
Added in API level 3Get the position of the dropdown view selection, if there is one. Returns
if there is no dropdown or if there is no selection.
ListView.INVALID_POSITION
Returns
- the position of the current selection, if there is one, or
ListView.INVALID_POSITION
if not.
See Also
public AdapterView.OnItemClickListener getOnItemClickListener()
Added in API level 3Returns the listener that is notified whenever the user clicks an item in the drop down list.
Returns
- the item click listener
public AdapterView.OnItemSelectedListener getOnItemSelectedListener()
Added in API level 3Returns the listener that is notified whenever the user selects an item in the drop down list.
Returns
- the item selected listener
public int getThreshold()
Added in API level 1Returns the number of characters the user must type before the drop down list is shown.
Related XML Attributes
Returns
- the minimum number of characters to type to show the drop down
See Also
public AutoCompleteTextView.Validator getValidator()
Added in API level 1Returns the Validator set with setValidator(AutoCompleteTextView.Validator)
, or null
if it was not set.
See Also
public boolean isPerformingCompletion()
Added in API level 3Identifies whether the view is currently performing a text completion, so subclasses can decide whether to respond to text changed events.
public boolean isPopupShowing()
Added in API level 1Indicates whether the popup menu is showing.
Returns
- true if the popup menu is showing, false otherwise
public void onCommitCompletion(CompletionInfo completion)
Added in API level 3Called by the framework in response to a text completion from the current input method, provided by it callingInputConnection.commitCompletion()
. The default implementation does nothing; text views that are supporting auto-completion should override this to do their desired behavior.
Parameters
completion | The auto complete text the user has selected. |
---|
public void onFilterComplete(int count)
Added in API level 1Notifies the end of a filtering operation.
Parameters
count | the number of values computed by the filter |
---|
public boolean onKeyDown(int keyCode, KeyEvent event)
Added in API level 1Default implementation of KeyEvent.Callback.onKeyDown()
: perform press of the view whenKEYCODE_DPAD_CENTER
orKEYCODE_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.
Parameters
keyCode | A key code that represents the button pressed, from KeyEvent . |
---|---|
event | The KeyEvent object that defines the button action. |
Returns
- If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
public boolean onKeyPreIme(int keyCode, KeyEvent event)
Added in API level 3Handle a key event before it is processed by any input method associated with the view hierarchy. This can be used to intercept key events in special situations before the IME consumes them; a typical example would be handling the BACK key to update the application's UI instead of allowing the IME to see it and close itself.
Parameters
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
Returns
- If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
public boolean onKeyUp(int keyCode, KeyEvent event)
Added in API level 1Default implementation of KeyEvent.Callback.onKeyUp()
: perform clicking of the view whenKEYCODE_DPAD_CENTER
orKEYCODE_ENTER
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.
Parameters
keyCode | A key code that represents the button pressed, from KeyEvent . |
---|---|
event | The KeyEvent object that defines the button action. |
Returns
- If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
public void onWindowFocusChanged(boolean hasWindowFocus)
Added in API level 1Called when the window containing this view gains or loses focus. Note that this is separate from view focus: to receive key events, both your view and its window must have focus. If a window is displayed on top of yours that takes input focus, then your own window will lose focus but the view focus will remain unchanged.
Parameters
hasWindowFocus | True if the window containing this view now has focus, false otherwise. |
---|
public void performCompletion()
Added in API level 1Performs 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 performValidation()
Added in API level 1If a validator was set on this view and the current string is not valid, ask the validator to fix it.
See Also
public void setAdapter(T adapter)
Added in API level 1Changes 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 ofCursorAdapter
, which contains aCursor
that must be closed. This can be done automatically (seestartManagingCursor()
), or by manually closing the cursor when the AutoCompleteTextView is dismissed.
Parameters
adapter | the adapter holding the auto completion data |
---|
See Also
public void setCompletionHint(CharSequence hint)
Added in API level 1Sets 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.
Related XML Attributes
Parameters
hint | the text to be displayed to the user |
---|
See Also
public void setDropDownAnchor(int id)
Added in API level 3Sets 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.
Related XML Attributes
Parameters
id | the id to anchor the drop down list view to |
---|
public void setDropDownBackgroundDrawable(Drawable d)
Added in API level 5Sets the background of the auto-complete drop-down list.
Related XML Attributes
Parameters
d | the drawable to set as the background |
---|
public void setDropDownBackgroundResource(int id)
Added in API level 5Sets the background of the auto-complete drop-down list.
Related XML Attributes
Parameters
id | the id of the drawable to set as the background |
---|
public void setDropDownHeight(int height)
Added in API level 4Sets the current height for the auto-complete drop down list. This can be a fixed height, orMATCH_PARENT
to fill the screen, orWRAP_CONTENT
to fit the height of the drop down's content.
Related XML Attributes
Parameters
height | the height to use |
---|
public void setDropDownHorizontalOffset(int offset)
Added in API level 5Sets the horizontal offset used for the auto-complete drop-down list.
Parameters
offset | the horizontal offset |
---|
public void setDropDownVerticalOffset(int offset)
Added in API level 5Sets the vertical offset used for the auto-complete drop-down list.
Parameters
offset | the vertical offset |
---|
public void setDropDownWidth(int width)
Added in API level 3Sets the current width for the auto-complete drop down list. This can be a fixed width, orMATCH_PARENT
to fill the screen, orWRAP_CONTENT
to fit the width of its anchor view.
Related XML Attributes
Parameters
width | the width to use |
---|
public void setListSelection(int position)
Added in API level 3Set the position of the dropdown view selection.
Parameters
position | The position to move the selector to. |
---|
public void setOnClickListener(View.OnClickListener listener)
Added in API level 1Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable.
Parameters
listener | The callback that will run |
---|
public void setOnDismissListener(AutoCompleteTextView.OnDismissListener dismissListener)
Added in API level 17Set a listener that will be invoked whenever the AutoCompleteTextView's list of completions is dismissed.
Parameters
dismissListener | Listener to invoke when completions are dismissed |
---|
public void setOnItemClickListener(AdapterView.OnItemClickListener l)
Added in API level 1Sets the listener that will be notified when the user clicks an item in the drop down list.
Parameters
l | the item click listener |
---|
public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener l)
Added in API level 1Sets the listener that will be notified when the user selects an item in the drop down list.
Parameters
l | the item selected listener |
---|
public void setText(CharSequence text, boolean filter)
Added in API level 17Like setText(CharSequence)
, except that it can disable filtering.
Parameters
filter | If false , no filtering will be performed as a result of this call. |
---|
public void setThreshold(int threshold)
Added in API level 1Specifies 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.
Related XML Attributes
Parameters
threshold | the number of characters to type before the drop down is shown |
---|
See Also
public void setValidator(AutoCompleteTextView.Validator validator)
Added in API level 1Sets the validator used to perform text validation.
Parameters
validator | The validator used to validate the text entered in this widget. |
---|
See Also
public void showDropDown()
Added in API level 1Displays the drop down on screen.
Protected Methods
protected CharSequence convertSelectionToString (Object selectedItem)
Added in API level 1Converts the selected item from the drop down list into a sequence of character that can be used in the edit box.
Parameters
selectedItem | the item selected by the user for completion |
---|
Returns
- a sequence of characters representing the selected suggestion
protected Filter getFilter ()
Added in API level 1Returns the Filter obtained from getFilter()
, ornull
if setAdapter(T)
was not called with a Filterable.
protected void onAttachedToWindow()
Added in API level 1This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called beforeonDraw(android.graphics.Canvas)
, however it may be called any time before the first onDraw -- including before or afteronMeasure(int, int)
.
protected void onDetachedFromWindow()
Added in API level 1This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
protected void onDisplayHint(int hint)
Added in API level 8Gives this view a hint about whether is displayed or not. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should notrely on this hint as there is no guarantee that they will receive one.
Parameters
hint | A hint about whether or not this view is displayed: VISIBLE orINVISIBLE . |
---|
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
Added in API level 1Called by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from. When overriding, be sure to call up through to the super class so that the standard focus handling will occur.
Parameters
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 areFOCUS_UP ,FOCUS_DOWN ,FOCUS_LEFT ,FOCUS_RIGHT ,FOCUS_FORWARD , orFOCUS_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 benull otherwise. |
protected void performFiltering(CharSequence text, int keyCode)
Added in API level 1Starts 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 oftext
.
Parameters
text | the filtering pattern |
---|---|
keyCode | the last character inserted in the edit box; beware that this will be null when text is being added through a soft input method. |
protected void replaceText(CharSequence text)
Added in API level 1Performs 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.
Parameters
text | the selected suggestion in the drop down list |
---|
protected boolean setFrame(int l, int t, int r, int b)
Added in API level 1Assign a size and position to this view. This is called from layout.
Parameters
l | Left position, relative to parent |
---|---|
t | Top position, relative to parent |
r | Right position, relative to parent |
b | Bottom position, relative to parent |
Returns
- true if the new size and position are different than the previous ones
使用方法如下:
public classCountriesActivity extendsActivity {
protected void onCreate(Bundle icicle){
super.onCreate(icicle);
setContentView(R.layout.countries);
ArrayAdapter<String> adapter= newArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView= (AutoCompleteTextView)
findViewById(R.id.countries_list);
textView.setAdapter(adapter);
}
private staticfinal String[] COUNTRIES= newString[]{
"Belgium","France","Italy","Germany","Spain"
};
}