Reputation: 7937
I have a custom AutoCompleteTextView
where the user can enter text and whenever the user writes @ I show a dropdown with suggestions of custom usernames. Unfortunately, I also need to show the dictionary word suggestions above the keyboard and, for some reason, AutoCompleteTextView
doesn't show dictionary suggestions, although it inherits from EditText
where it does show.
So, does anyone know what the problem is and how to fix it? Or should I go to a different route to obtain what I want.
Upvotes: 3
Views: 1114
Reputation: 870
I had the same issue, I recommend extend AutocompleteTextView
class and add this line in each constructor:
setInputType(getInputType() & (~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE));
Upvotes: 0
Reputation: 141
I ran into the same problem. The AutoCompleteTextView
constructor sets the InputType
flag EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE
. I confirmed that this flag inhibits the normal text suggestions. The code reads:
// Always turn on the auto complete input type flag, since it
// makes no sense to use this widget without it.
int inputType = getInputType();
if ((inputType&EditorInfo.TYPE_MASK_CLASS)
== EditorInfo.TYPE_CLASS_TEXT) {
inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
setRawInputType(inputType);
}
Despite this comment, I've had preliminary success with removing the flag, as in:
AutoCompleteTextView t = (AutoCompleteTextView)v.findViewById(id);
t.setInputType( t.getInputType() & (~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE) );
Upvotes: 1