嗨,我有一个编辑框,如果用户键入过滤应该在列表视图中自动完成...
从下面的代码一切正常,但如果我在字符中放置空格,则列表视图不会显示任何条目..
下面是我的代码
adapter = new SimpleAdapter(PredefinedLocation.this, fillMaps, R.layout.list_item_deal, new String[] { "name" }, new int[] { R.id.name });
// Adding data into listview
lv.setAdapter(adapter);
edtSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
lv.setTextFilterEnabled(true);
lv.setFilterText(s.toString().trim());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if(s.length()==0){
lv.clearTextFilter();
}
}
});
就像我写“The”一样,结果将是“The Local”、“The Adams”
但是如果我写“The Local”,结果将是空白的......因为“The”和“Local”中有空格:(