AutoCompleteTextView does not show dictionary suggestions

I have a custom AutoCompleteTextView where the user can enter text and whenever the user writes @, I show a drop-down list with suggestions for user names. Unfortunately, I also need to show vocabulary sentences above the keyboard, and for some reason AutoCompleteTextView does not display vocabulary sentences, although it inherits from EditText where it displays.

So, does anyone know what the problem is and how to fix it? Or should I go the other way to get what I want.

+3
android autocompletetextview
source share
2 answers

I ran into the same problem. The AutoCompleteTextView constructor sets the InputType EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE flag. I have confirmed that this flag prohibits regular text sentences. 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 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) ); 
+1
source share

I had the same problem, I recommend extending the AutocompleteTextView class and adding this line to each constructor:

 setInputType(getInputType() & (~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE)); 
0
source share

All Articles