AutoCompleteTextView不显示字典中的建议 [英] AutoCompleteTextView doesn't show dictionary suggestions
问题描述
我有一个自定义的 AutoCompleteTextView
用户可以在其中输入文本,当用户写@我显示自定义的用户名的建议下拉。不幸的是,我还需要显示键盘上方的字典单词和建议,出于某种原因, AutoCompleteTextView
不显示字典中的建议,虽然它从的EditText
在这里显示出来。
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.
推荐答案
我遇到了同样的问题。在 AutoCompleteTextView
构造函数将 inputType下
标记 EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE
。我确认这标志抑制了正常的文本建议。在code读取:
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);
}
尽管这样的评论,我有preliminary成功与删除标志,如:
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) );
这篇关于AutoCompleteTextView不显示字典中的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!