我有一个 AutoCompleteTextView
我用从一个长长的清单中选择一个项目。用户应该只能够从列表中选择pdetermined项的$ P $。他们应该无法进入自己的项目。
I have an AutoCompleteTextView
I use to select an item from a long list. The user should only be able to select a predetermined item from the list. They should not be able to enter their own item.
我检查,以确保它们从列表中只提交一个项目的方法是使用 setOnItemClickListener
来触发布尔标志。现在的问题是,经过布尔标志设置为true,他们仍然可以编辑该项目的选定文本。我需要检测这一点,并重新设置布尔标志设置为false。如何做到这一点。我见过一个建议使用的onkeydown
,但我不知道如何实现这一点。
The way I check to make sure they submit only an item from the list is to use setOnItemClickListener
to trigger a boolean flag. The problem is that after the boolean flag is set to true, they can still edit the selected text of the item. I need to detect this and set the boolean flag to false again. How do I do this. I have seen a suggestion to use onKeyDown
, but I am not sure how to implement this.
您可以添加文字修改监听器:
You can add text changed listener:
autoCompleteTextView.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
上一篇:不读书嵌套parcelable对象嵌套、对象、parcelable
下一篇:ClassNotFoundException的时候,包括库JAR时候、ClassNotFoundException、JAR