Reputation: 11331
I am trying to implement a functionality like Twitter: when user type in '@', a dropdown menu shows-up with some suggestions.
Here's my current code:
mTextBox = (AutoCompleteTextView) findViewById(R.id.text);
String[] testArray = {"aaa", "aabc", "aaaa", "bbb" , "bcd", "zzz", "fff", "ndc"};
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, testArray);
adapter.setNotifyOnChange(true);
mTextBox.setAdapter(adapter);
Currently, the behavior of the AutoCompleteTextView is, when I type in part of the word, the full suggestion shows up. For example, when I type in a
, it shows nothing, when I type in aa
, then it shows suggestion of aabc
, aaa
and aaaa
.
How can I make it so when I type in @
, it shows a list of all available options?
Thank you
Upvotes: 0
Views: 76
Reputation: 51
Add the following attribute into your AutocompleteTextView of xml file
android:completionThreshold="1"
Upvotes: 1