安卓立即自动完成 [英] Android Immediate Auto Complete
本文介绍了安卓立即自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好!
Android的自动完成功能只有启动后两个字母,我怎样才能使它所以当现场只是选择列表中出现?
The android auto complete only starts after two letters, how can I make it so the list appears when the field is just selected?
感谢
推荐答案
延长AutoCompleteTextView,覆盖enoughToFilter()方法和阈值方法,所以它不会与1阈值替换0阈值:
Extend the AutoCompleteTextView, overriding the enoughToFilter() methods and the threshold methods so that it doesn't replace the 0 threshold with a 1 threshold:
public class MyAutoCompleteTextView extends AutoCompleteTextView {
private int myThreshold;
public MyAutoCompleteTextView(Context context) {
super(context);
}
public MyAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void setThreshold(int threshold) {
if (threshold < 0) {
threshold = 0;
}
myThreshold = threshold;
}
@Override
public boolean enoughToFilter() {
return getText().length() >= myThreshold;
}
@Override
public int getThreshold() {
return myThreshold;
}
}
这篇关于安卓立即自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文