In most of the applications user wants suggestions from a ListView/Source while typing in an editable text field. For that particular thing we have two different editable TextViews which provide a drop down menu.
AutoCompleteTextView only offers the suggestions automatically about the whole sentence, from which user can easily choose a prefered item.
//Initializing AutoCompleteTextView and ListView
acTextView=(AutoCompleteTextView)findViewById(R.id.acTextView);
lvListDisplay=(ListView)findViewById(R.id.lvListDisplay);
//Adapter works as a communication channel between UI components and the datasource that fill data into the UI Components.
final ArrayAdapter<String> adapter=new ArrayAdapter<String>(HomeScreenActivity.this,android.R.layout.simple_list_item_1,datasource);
lvListDisplay.setAdapter(adapter);
acTextView.setAdapter(adapter);
acTextView.setThreshold(1);
MultiAutoCompleteTextView make ease to the user by offering suggestion automatically for every token used in the sentence.
//Initialize MultiAutoCompleteTextView
macTextView=(MultiAutoCompleteTextView)findViewById(R.id.macTextView);
//Finally attaching adapter to the MultiAutoCompleteTextView
macTextView.setAdapter(adapter);
macTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
macTextView.setThreshold(1);
0 Comment(s)