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.
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) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With