搜索视图输入空格后显示空白
重复问题-点击,但使用回收器视图不适合我。还有其他选择吗? 如果你能帮助我,我会很高兴的。我正在过滤:
mySearchView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
adapter.getFilter().filter(s);
}
});
public static void main(String[] args){
// Creating a list of Integers
List<Integer> list = Arrays.asList(3, 4, 6, 12, 20);
// Getting a stream consisting of the
// elements that are divisible by 5
// Using Stream filter(Predicate predicate)
list.stream()
.filter(num -> num % 5 == 0)
.forEach(System.out::println);
}
您必须在onTextChanged中编写代码。
mySearchView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s);
}
@Override
public void afterTextChanged(Editable s) {
}
});