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)