Joe Rakhimov
Joe Rakhimov

Reputation: 5083

Cursor issue in SimpleCursorAdapter

Followed this tutorial, faced cursor problem in SimpleCursorAdapter. In tutorial example working as intended. In my code it is showing an error "The constructor SimpleCursorAdapter is undefined". No idea what was undefined. Code look like this:

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);

Upvotes: 0

Views: 173

Answers (1)

Zoubiock
Zoubiock

Reputation: 1165

Did you import the class ?

import android.widget.SimpleCursorAdapter;

If you did, then be sure to call the constructor with the right kind of parameters. "this" should stand for an activity or a context. if you are in a Runnable or in a clicklistener you will have to call the super MyActivty.this

Upvotes: 1

Related Questions