Android Auto-complete text box-android learning Journey (26)

Source: Internet
Author: User

Autocomplicatedtextview Introduction

The Autocomplicatedtextview is derived from edittext and can use all the properties of the EditText. When the user enters a certain content, there will be a prompt, selected after auto-fill. By the way, the Multiautocomplicatedtextview is basically similar to the above usage, except that you can enter multiple prompt entries, then separate them with delimiters and set the delimiter with Settokenize ().

Properties Introduction

Code
Package Peng. Liu. TestView;Import Android. App. Activity;Import Android. Graphics. Color;Import Android. OS. Bundle;Import Android. View. View;Import Android. View. ViewGroup;Import Android. Widgets. Arrayadapter;Import Android. Widgets. Autocompletetextview;Import Android. Widgets. Baseadapter;Import Android. Widgets. ImageView;Import Android. Widgets. LinearLayout;Import Android. Widgets. ListView;Import Android. Widgets. Multiautocompletetextview;Import Android. Widgets. Simpleadapter;Import Android. Widgets. TextView;Import Java. Util. ArrayList;Import Java. Util. HashMap;Import Java. Util. List;Import Java. Util. Map;public class Mainactivity extends Activity {private Autocompletetextview Auto;Private Multiautocompletetextview Mauto;Private string[] names = new string[]{"Hello","World","Java","Android"};@Override protected void OnCreate (Bundle savedinstancestate) {Super. OnCreate(savedinstancestate);Setcontentview (R. Layout. Activity_main);arrayadapter<string> adapter = new Arrayadapter<string> (this,android. R. Layout. Simple_list_item_1,names);Auto = (Autocompletetextview) Findviewbyid (R. ID. Auto);Mauto = (Multiautocompletetextview) Findviewbyid (R. ID. Mauto);Auto. Setadapter(adapter);Mauto. Setadapter(adapter);Mauto. Settokenizer(New Multiautocompletetextview. Commatokenizer());}}
<LinearLayout xmlns:android="Http://schemas.android.com/apk/res/android"    Xmlns:tools="Http://schemas.android.com/tools" Android:layout_width="Match_parent"    Android:layout_height="Match_parent" Android:paddingleft="@dimen/activity_horizontal_margin"    Android:paddingright="@dimen/activity_horizontal_margin"    Android:paddingtop="@dimen/activity_vertical_margin"    Android:paddingbottom="@dimen/activity_vertical_margin"    Tools:context=". Mainactivity "    android:orientation="Vertical">   <autocompletetextview   Android:layout_width  = "fill_parent"  android: Layout_height  = "wrap_content"  android:id  = "@+id/auto"  android:completionhint  =        "Choose your favorite Books"  android:dropdownhorizontaloffset  = "10DP"  Span class= "Hljs-attribute" >android:completionthreshold  = "1" />     <multiautocompletetextviewandroid:id="@+id/mauto"android:layout_width ="Fill_parent"android:layout_height="Wrap_content"android: Completionthreshold="1"/>                                </linearlayout>

Android Auto-complete text box-android learning Journey (26)

Related Article

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.