I have created a filter listview where user will enter input via edittext and results are filtered in the listview.
The code is running good but when ever i press Sp
do this way:
public void afterTextChanged(Editable s) {
String st = s.toString().trim();
NearByActivity.this.aa.getFilter().filter(st);
}
but don't do filtering this way, here is the correct one.
I found solution:
String[] hi={"Hi there", "Hello", "Bye"};
adapter = new ArrayAdapter<String>(slownik.this, R.layout.list_item, R.id.word_name,hi);
lv.setAdapter(adapter);
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
lv.setTextFilterEnabled(true);
lv.setFilterText(s.toString().trim());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
slownik.this.adapter.getFilter().filter(s.toString().trim());
if(s.length()==0){
lv.clearTextFilter();
}
}
});