Automatically complete the use of the editable text autocompletetextview

Source: Internet
Author: User

The input boxes used to search for information in Baidu or Google can all display the relevant search keywords in the drop-down menu when we enter a small amount of text, you can select the keyword you want to search for to quickly obtain the required information. This function uses the automatically completed editable text input box control. In Android UI development, there is also a control named autocompletetextview. With this control, we can implement UI functions similar to the search box.
The following ataaw. com lists how to use autocompletetextview in Android.

A. The corresponding position declaration in the layout file automatically completes the Editable Space
<Autocompletetextview
Android: Id = "@ + ID/edittext"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
/>

B.ProgramLoad Android Layout
Setcontentview (R. layout. autocompletetextview );

C. Construct a data source. Generally, an array is used or the data source is obtained through the database.
Private string [] ary = new string [] {
"Ataaw. com ",
"Anytime, anywhere ",
"Impromptu Times ",
"Android ",
"Google ",
};

D. Create an adapter for the space through the data source
Arrayadapter <string> adapter = new arrayadapter <string> (
This,
Android. R. layout. simple_dropdown_item_1line, // the style that comes with Android is used here.
Ary );

E. Create an adapter for the control
Autocompletetextview textview = (autocompletetextview) findviewbyid (R. Id. edittext );
Textview. setadapter (adapter );

So far, an automatically completed autocompletetextview editable text box is complete.

From: http://www.ataaw.com/develop/242.html

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.