Android ApiDemos example resolution (102): Views-& gt; Auto Complete-& g

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.