ExpandableListView.setAdapter() throws IllegalStateException

Posted by vijay on Stack Overflow See other posts from Stack Overflow or by vijay
Published on 2012-09-19T16:18:39Z Indexed on 2012/09/20 9:38 UTC
Read the original article Hit count: 200

Filed under:
|

I am getting the following exception:

java.lang.IllegalStateException: get field slot from row 0 col -1 failed 

when I call setAdapter() on my ExpandableListView. Can someone please help me fix this problem? (I have already wasted 2 days :( )

Cursor mCursor = tasksListCursor(); 
    Log.i("ChronicleTaskList", "rowcount: "+mCursor.getCount());
    startManagingCursor(mCursor);
    boolean flag = mCursor.moveToFirst();
    while (flag) {   // This loop executes fine.
        long id = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_ID));
        String name = mCursor.getString(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_NAME));
        long from = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_FROM));
        long to = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_TO));
        Log.i("ChronicleTaskList", id + ", "+ name+ ", "+ from+ ", "+to);
        flag = mCursor.moveToNext();
    }
    String[] grpFromCols = { ChronicleDb.KEY_NAME};
    int[] grpToVals = { R.id.cGroupRowTextName };
    String[] fromCols = { TasksDbAdapter.KEY_TODODATE,
            TasksDbAdapter.KEY_NAME };
    int[] toVals = { R.id.textViewDate2, R.id.taskRowTextTask };

    ChronicleTreeListAdapterSimple adapter = new ChronicleTreeListAdapterSimple(this, mCursor, 
            R.layout.c_group_row, grpFromCols, grpToVals, 
            R.layout.task_row2, fromCols, toVals, true);
    expandableListView.setAdapter(adapter);    

The last line throws the exception.

And the Adapter looks like this:

public class ChronicleTreeListAdapterSimple extends SimpleCursorTreeAdapter {
protected static String TAG = "ChronicleTreeListAdapter";

public ChronicleTreeListAdapterSimple(
        ChronicleTaskList context, Cursor cursor,
        int groupLayout, String[] groupFrom, int[] groupTo, 
        int childLayout, String[] childFrom, int[] childTo,
        boolean showGroupName) {
    super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childFrom, childTo);
    taskList = context;
}

© Stack Overflow or respective owner

Related posts about android

Related posts about expandablelistview