3
我想用cursoradapter過濾我的列表視圖。這是我迄今爲止所嘗試的:Android的cursoradapter過濾器列表視圖
CustomAdapter adapter;
Cursor cursor;
etSearch.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence cs, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
adapter.getFilter().filter(cs.toString());
}
});
cursor = dbHelper.getAllItemInventoryListings();
adapter = new CustomAdapter(this, cursor);
lv.setAdapter(adapter);
lv.setTextFilterEnabled(true);
adapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
String strItemCode = constraint.toString();
return dbHelper.getAllItemInventoryListings(strItemCode);
}
});
當我嘗試它不過濾。什麼似乎是錯的?您的幫助將不勝感激。謝謝。
它現在! :) 謝謝 – Dunkey