Android advanced component AutoCompleteTextView autocomplete text box usage details
Autocomplete textview is used to display a drop-down menu for users to select after allowing users to enter certain characters. When users select an option, the text box will be filled in automatically according to the user's selection.
Syntax format:
< AutoCompleteTextView attribute list > < / AutoCompleteTextView >
The AutoCompleteTextView component inherits EditText, so it supports the properties provided by the EditText component. At the same time, The component also has the following attributes: Android: completionhint drop-down list the following descriptive text Android: completionthreshold the minimum number of characters in the pop-up list Android: dropdownanchor drop-down list anchor or mount point Android: dropdownheight drop-down list height Android: dropdownwidth drop-down list width Android: dropdownhorizontaloffset drop-down list distance Distance from the left Android: dropdownverticaloffset drop-down list distance from the top Android: dropdownselector drop-down list background of the selected row Android: popupbackground drop-down list background
The following implements the search box with automatic prompt function:
The effect is shown in the figure:
Specific implementation:
res/layout/main.xml:
The interface effect is shown in the figure below:
MainActivity:
Automatic completion is realized. When you hit Henan, there will be completion information below. This function is widely used in search applications.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.