java.lang.IllegalStateException:从第 0 行第 0 行获取字段槽失败

发布于 2024-11-19 20:14:40 字数 5567 浏览 5 评论 0原文

嘿,我正在尝试使用 AlphabetIndexer 实现 FastScroller。我正在列表视图中使用 500 个联系人进行测试。

当尝试快速滚动它时,它会返回以下错误:

java.lang.IllegalStateException:从第 0 行第 0 行获取字段槽 失败

在这个方法中:

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

我假设: mAlphaIndexer.getPositionForSection(section) 返回“0”,因为我已经在这一行中放置了一个日志。并且错误出现在日志中,不再出现在返回中。

编辑:

LogCat 中显示一个错误,这让我感到困惑和担心,因为我试图在列表视图中设置图像和文本以及复选框,因此对于每个视图我设置一个图像和一个文本视图和复选框。出现了这个错误:

错误/CursorWindow(24241):需要增大:mSize = 1048576,大小 = 7702, freeSpace() = 3474,numRows = 135 错误/CursorWindow(24241):不是 由于已经有 135 行,最大大小 1048576,因此不断增长 错误/光标(24241):无法为 134,5 处的 blob 分配 7702 字节

我想这是因为它的大小,因为我正在测试在 ListView 中创建超过 1000 个项目。这是可能的错误吗?

它还显示在 LogCat 上:

错误/CursorWindow(24098):字段槽 0,0 的请求错误。行数 = 0,列数 = 0

这是我的 CursorAdapter 构造函数:

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

游标不为空,也不关闭(打印日志消息)。

完整的LOGCAT!粗体线是错误出现的地方,这是帖子开头发布的第一个方法。

07-14 09:40:49.042: 错误/AndroidRuntime(24098): 致命异常: main 07-14 09:40:49.042: 错误/AndroidRuntime(24098): java.lang.IllegalStateException:从第 0 行第 0 行获取字段槽 失败 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.database.CursorWindow.getLong_native(原生方法) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.database.CursorWindow.getLong(CursorWindow.java:380) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:108) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.database.AbstractCursor.moveToPosition(AbstractCursor.java:194) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.widget.AlphabetIndexer.getPositionForSection(AlphabetIndexer.java:202) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 com.test.myapplication.MyCursorAdapter.getPositionForSection(MyCursorAdapter.java:181) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.widget.FastScroller.scrollTo(FastScroller.java:324) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.widget.FastScroller.onTouchEvent(FastScroller.java:471) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.widget.AbsListView.onTouchEvent(AbsListView.java:2104) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.widget.ListView.onTouchEvent(ListView.java:3446) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.View.dispatchTouchEvent(View.java:3885) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.app.Activity.dispatchTouchEvent(Activity.java:2096) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.view.ViewRoot.handleMessage(ViewRoot.java:1878) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.os.Handler.dispatchMessage(Handler.java:99) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 android.os.Looper.loop(Looper.java:130) 07-14 09:40:49.042: 错误/Android运行时(24098):位于 android.app.ActivityThread.main(ActivityThread.java:3683) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 java.lang.reflect.Method.invokeNative(原生方法) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 java.lang.reflect.Method.invoke(Method.java:507) 07-14 09:40:49.042: 错误/Android运行时(24098):位于 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 07-14 09:40:49.042: 错误/AndroidRuntime(24098): 在 dalvik.system.NativeStart.main(本机方法)

如何解决?谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小镇女孩 2024-11-26 20:14:40

发生错误的原因是 CursorWindow 类仅支持读取 1MB 的数据查询,所以我必须优化我的查询。

我只是在数据库中搜索数据,在列表视图中搜索当前视图,所以我不需要查询所有数据。

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.

空心空情空意 2024-11-26 20:14:40

您是否通过调用 setCursor(cursor) 来设置光标?您的光标此时有效吗?

Have you set cursor by calling setCursor(cursor) ? Is your cursor valid at this point in time?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文