我已经创建了自定义autocompletetextview组件。我还为自动完成文本数据创建了一个populateList方法。
final com.example.admin.ctronhot.autocomleteclass autocomplete=(com.example.admin.ctronhot.autocomleteclass)findViewById(R.id.abc);
final String sql="select * from g101 where desc LIKE '%" + autocomplete.getText().toString() + "%'";
final String[] mfieldsa=new String[]{"desc"};
final int[] mobjectsa=new int[]{R.id.desc};
autocomplete.populateList(R.layout.brow_g101_layout, sql, "desc", aa, mfieldsa, mobjectsa, order.this);
显示下拉数据,但未按照autocomplete.getText.toString()中的类型过滤数据
这是我的函数populateList
public void populateList(Integer _layoutfile, final String sqlaa, String mfieldget, com.example.admin.ctronhot.autocomleteclass mauto,
String[] mfields, int[] mobjects, Context mcontext) {
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(co.mcurd_data_path_, null);
Cursor cursor = db.rawQuery(sqlaa null);
int layoutResourceId = 0;
final SimpleCursorAdapter adapter = new SimpeCursorAdapter(
mcontext, // Context
_layoutfile, // Row layout template
cursor, // cursor (set of DB records to map)
mfields, // DB Column names
mobjects // View IDs to put information in
, layoutResourceId
);
adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
@Override
public CharSequence convertToString(Cursor cursor) {
final int colIndex = cursor.getColumnIndexOrThrow("desc");
return cursor.getString(colIndex);
}
});
adapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence description) {
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(co.mcurd_data_path_, null);
Cursor managedCursor = db.rawQuery(sqlaa, null);
return managedCursor;
}
});
mauto.setThreshold(1);
mauto.setAdapter(adapter);
}
请帮帮我。 提前谢谢。