Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to replace MultiAutoCompleteTextView drop down list
    text
    copied!<p>I'm trying to replace MultiAutoCompleteTextView Drop down list with a ListView, which it should have same functionality as drop down list, that means, when I click in one of items it should be added to MultiAutoCompleteTextView box, o so on, but filtering the ListView as you type.</p> <p>So I came up with this raw code without success:</p> <p>filterable_listview.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"&gt; &lt;MultiAutoCompleteTextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:hint="@string/To" android:id="@+id/search_box"&gt;&lt;/MultiAutoCompleteTextView&gt; &lt;ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>AutoCompleteActivity.java</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.filterable_listview); manager = new ContactManager(); adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, manager.getContacts()); searchEdit = (MultiAutoCompleteTextView) findViewById(R.id.search_box); searchEdit.addTextChangedListener(filterTextWatcher); searchEdit.setTokenizer(new SpaceTokenizer()); setListAdapter(adapter); getListView().setOnItemClickListener( new ListView.OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { //Here is one issues searchEdit.append(adapter.getItem(position)); } }); } private TextWatcher filterTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count,int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); } }; </code></pre> <p>I have to main problems:</p> <p>1) When I click an item, the whole selected text is appended, I know the problem relies on:</p> <p>searchEdit.append(adapter.getItem(position)); </p> <p>but, How can I do spanning text like regular autocomplete does ?</p> <p>2) Once one item was selected, next input don't show the suggestion any more (despite of SpaceTonekizer)</p> <p>I hope my explanation was clear.</p> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload