SetAdapter method of AutoCompleteTextView:
Public void setAdapter (T adapter)
Set the example table of the automatic prompt drop-down box, which is an Adapter type. To support the Adapter of the filterable list, the commonly implemented Adapter of the Filterable is ArrayAdapter, CursorAdapter, SimpleAdatper, SimpleCursorAdapter, and so on.
The application is responsible for managing the resources involved with the Adapter, because the adapter is not notified when AutoCompleteTextView is disabled. For example, the application must release the Cursor resources contained in the CursorAdapter. You can use startManagingCursor () to automatically manage cursor or manually release Cursor when AutoCompleteTextView is disabled.
This example uses CursorAdapter to use ContentResolver to read contacts in the address book as the content source of the prompt box. For ContentResolver and Contact List usage, see Android ApiDemos example resolution (10): App-> Activity-> QuickContactsDemo
In this example, ContactListAdapter supports * wildcard to match all contacts. Because * has a length of 1, android: completionThreshold:
<AutoCompleteTextView android: id = "@ + id/edit"
Android: completionThreshold = "1 ″
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"/>
Set the adapter for AutoCompleteTextView.
[Java]
AutoCompleteTextView textView = (AutoCompleteTextView)
FindViewById (R. id. edit );
TextView. setAdapter (adapter );
AutoCompleteTextView textView = (AutoCompleteTextView)
FindViewById (R. id. edit );
TextView. setAdapter (adapter );
Author: mapdigit