0
跟着這個tutorial,在SimpleCursorAdapter中遇到了光標問題。在教程示例中按預期工作。在我的代碼中顯示錯誤「構造函數SimpleCursorAdapter未定義」。不知道什麼是未定義的。代碼如下所示:SimpleCursorAdapter中的光標問題
Cursor cursor = null;
if (inputText == null || inputText.length() == 0) {
cursor = myDataBase.query(true, GL_TABLE, new String[] { GL_ID,
GL_FK, GL_LANG, GL_VALUE}, GL_FK
+ " like '%" + inputText + "%'", null, null, null, null,
null);
} else {
cursor = myDataBase.query(true, GL_TABLE, new String[] { GL_ID,
GL_FK, GL_LANG, GL_VALUE}, GL_VALUE
+ " like '%" + inputText + "%'", null, null, null, null,
null);
}
if (cursor != null) {
cursor.moveToFirst();
}
String[] columns = new String[] { GL_FK, GL_LANG, GL_VALUE};
int[] to = new int[] { R.id.tvWord, R.id.tvMeaning, R.id.tvKanji};
dataAdapter = new SimpleCursorAdapter(this, R.layout.listword,
cursor, columns, to, 0);
錯誤在這裏:dataAdapter = new SimpleCursorAdapter(this,R.layout.listword, ** cursor **,columns,to ,0); –