Search code examples
androidandroid-listviewandroid-scrollbar

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


Hey I'm trying to implement an FastScroller with AlphabetIndexer. And I'm testing it with 500 contacts in a list view.

And when trying to fast scroll it, it returns the folowing error:

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

In this method:

@Override
public int getPositionForSection(int section)
{
    return mAlphaIndexer.getPositionForSection(section);
}

I suposse this: mAlphaIndexer.getPositionForSection(section) is returning '0', due to the fact I've put a Log with this line. And the error showed up in the Log not in the returnment anymore.

Edit:

There is an error showing in LogCat that made me confused and worried, because I'm trying to set images and text and checkbox in a listview, so for each view I set an image and a text view and a checkbox. And this error came up:

ERROR/CursorWindow(24241): need to grow: mSize = 1048576, size = 7702, freeSpace() = 3474, numRows = 135 ERROR/CursorWindow(24241): not growing since there are already 135 row(s), max size 1048576 ERROR/Cursor(24241): Failed allocating 7702 bytes for blob at 134,5

I guess this is because of the size of it, due to the fact that I'm testing creating more then 1000 items in the ListView. Can that be the possible error?

it also shows on LogCat:

ERROR/CursorWindow(24098): Bad request for field slot 0,0. numRows = 0, numColumns = 0

Here is my CursorAdapter Constructor:

public MyCursorAdapter(Context context, Cursor cursor, ArrayList<Integer> ids) 
        {
            super(context, cursor);
            try
            {           

                mAlphaIndexer = new AlphabetIndexer(cursor, cursor.getColumnIndexOrThrow("Name")," ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            mAlphaIndexer.setCursor(cursor);
            if(!cursor.isClosed() && cursor != null)
            {
                Log.i("MyCursorAdapter", "Cursor opened and not null " + cursor);
            }
            this.mSelectedIndividuals = ids;
            catch(IllegalArgumentException ex)
            {
                Log.e("MyCursorAdapter", "Error: " + ex);
            }
        }

The cursor isnt null neither closed (The log message is printed).

FULL LOGCAT! The bold line is where the error shows up, that is the first method posted in the beggining of the post.

07-14 09:40:49.042: ERROR/AndroidRuntime(24098): FATAL EXCEPTION: main 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): java.lang.IllegalStateException: get field slot from row 0 col 0 failed 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.database.CursorWindow.getLong_native(Native Method) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.database.CursorWindow.getLong(CursorWindow.java:380) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:108) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:194) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.widget.AlphabetIndexer.getPositionForSection(AlphabetIndexer.java:202) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at com.test.myapplication.MyCursorAdapter.getPositionForSection(MyCursorAdapter.java:181) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.widget.FastScroller.scrollTo(FastScroller.java:324) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.widget.FastScroller.onTouchEvent(FastScroller.java:471) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.widget.AbsListView.onTouchEvent(AbsListView.java:2104) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.widget.ListView.onTouchEvent(ListView.java:3446) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.View.dispatchTouchEvent(View.java:3885) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.app.Activity.dispatchTouchEvent(Activity.java:2096) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.os.Handler.dispatchMessage(Handler.java:99) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.os.Looper.loop(Looper.java:130) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at android.app.ActivityThread.main(ActivityThread.java:3683) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at java.lang.reflect.Method.invokeNative(Native Method) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at java.lang.reflect.Method.invoke(Method.java:507) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 07-14 09:40:49.042: ERROR/AndroidRuntime(24098): at dalvik.system.NativeStart.main(Native Method)

How can I solve it? Thanks!


Solution

  • The error was happening because the CursorWindow class only supports reading 1MB of data per query, so I had to optimize my query.

    I only was searching for the data in the database, for the current views in the listview, so I wouldnt need to query all of the data.