安卓:AutoCompleteTextView显示建议时输入任何文字文字、建议、AutoCompleteTextView

2023-09-12 02:45:58 作者:除了死亡其他离开都是背叛

我使用AutoCompleteTextView,当用户点击它,我想说明的建议,即使它没有文字 - 但setThreshold(0)的作品完全一样setThreshold(1) - 因此,用户必须输入至少1字符显示的建议。

I am using AutoCompleteTextView , when user clicks on it, I want to show suggestions even if it has no text - but setThreshold(0) works exactly the same as setThreshold(1) - so the user has to enter at least 1 character to show the suggestions.

推荐答案

这是documented行为的:当阈值小于或等于0,1的阈值被施加

This is documented behavior: "When threshold is less than or equals 0, a threshold of 1 is applied.".

您可以手动表明通过 showDropDown下拉(),所以也许你可以安排,以显示它时,你想要的。或者,子类 AutoCompleteTextView 和覆盖 enoughToFilter(),返回所有时间。

You can manually show the drop-down via showDropDown(), so perhaps you can arrange to show it when you want. Or, subclass AutoCompleteTextView and override enoughToFilter(), returning true all of time.