我有一个EditText
来筛选它下面的ListView
中的项目,通常它可能包含超过1000个项目。该TextWatcher
是:如何让TextWatcher在做某些动作之前等待一段时间
txt_itemSearch.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
fillItemList();
}
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
});
的这里的问题是,由用户输入的每个字母,名单越来越刷新,这是导致该UI是缓慢的重复这个列表更新。
如何让TextWatcher
等待1-2秒,并且如果在2秒后没有更多输入发生,则过滤列表。任何建议家伙?
*任何建议家伙* - 使用使用适配器的'用getFilter(过滤'ListView'的正确方法)'方法。 – Luksprog
好的,但过滤有点复杂。我也有一些复选框和其他参数要过滤,所以我唯一的选择是通过SQLite查询来获取它。 – desidigitalnomad