splitwise / TokenAutoComplete

Gmail style MultiAutoCompleteTextView for Android
Apache License 2.0
1.3k stars 383 forks source link

How can I get the text entered, excluding the previous selected tokens? #217

Closed PinkFloyded closed 8 years ago

PinkFloyded commented 8 years ago

I'm trying to dynamically update the adapter per token by making a REST call. Is there a recommended way to do this using this widget? Also how do I get the text excluding previous selections, that is the current incomplete text so that I can make a REST call with that as a query?

PinkFloyded commented 8 years ago

I noticed that for each token that's selected, a comma and a space is added. I changed the query string to String text = countryCompletionView.getText().toString(); text = text.replace(",",""); text = text.replace(" ","");

Then change the adapter using citiesAdapter.notifyDataSetChanged();

Please let me know if there is a better way.

mgod commented 8 years ago

you should use currentCompletionText to get the text you should use for searching. You should be able to combine this with some kind of adapter that queries a remote source to search with REST calls. This isn't something I've done before, but there should be android tutorials for loading remote data into an adapter.

For getting the text excluding completions, you'll need to do some mangling on getText(). I don't really recommend this as the exact text formatting is not something I guarantee for future versions.