且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android中自定义的ListView搜索功能

更新时间:2023-10-14 23:01:52

尝试使用它

adapter.setFilterQueryProvider(new FilterQueryProvider() {
    public Cursor runQuery(CharSequence constraint) {
       // fetch all query data by input String
       // fetchDataByName take input String when search
       return dbHelper.fetchDataByName(constraint.toString());
    }
});


public void onTextChanged(CharSequence s, int start, int before,
            int count) {
     AbstractActivity.this.cursorAdapter.getFilter().filter(cs);       
}