java.lang.IllegalStateException:从第0行的字段获取字段槽0失败 [英] java.lang.IllegalStateException: get field slot from row 0 col 0 failed

查看:89
本文介绍了java.lang.IllegalStateException:从第0行的字段获取字段槽0失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:从第0行的字段获取字段槽0失败

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

在这种方法中:

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

我猜想这个: mAlphaIndexer.getPositionForSection(section)返回"0",原因是我已经在该行中放置了一个Log.错误出现在日志中,而不是返回中.

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.

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

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):需要增长:mSize = 1048576,size = 7702,freeSpace()= 3474,numRows = 135错误/CursorWindow(24241):不正在增长,因为已经有135行,最大尺寸为1048576错误/游标(24241):无法在134,5为blob分配7702个字节

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

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

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?

它也显示在LogCat上:

it also shows on LogCat:

ERROR/CursorWindow(24098):对字段插槽0,0的错误请求.numRows =0,numColumns = 0

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

这是我的CursorAdapter构造函数:

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

光标不为null也不关闭(打印日志消息).

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:错误/AndroidRuntime(24098):致命异常:主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-1409:40:49.042:错误/AndroidRuntime(24098):在android.database.CursorWindow.getLong(CursorWindow.java:380)07-1409: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-1409:40:49.042:错误/AndroidRuntime(24098):在android.widget.FastScroller.onTouchEvent(FastScroller.java:471)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.widget.AbsListView.onTouchEvent(AbsListView.java:2104)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.widget.ListView.onTouchEvent(ListView.java:3446)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.view.View.dispatchTouchEvent(View.java:3885)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)07-1409: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-1409: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-1409:40:49.042:错误/AndroidRuntime(24098):在android.view.ViewRoot.handleMessage(ViewRoot.java:1878)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.os.Handler.dispatchMessage(Handler.java:99)07-1409:40:49.042:错误/AndroidRuntime(24098):在android.os.Looper.loop(Looper.java:130)07-14 09:40:49.042:错误/AndroidRuntime(24098):在android.app.ActivityThread.main(ActivityThread.java:3683)07-1409:40:49.042:错误/AndroidRuntime(24098):在java.lang.reflect.Method.invokeNative(本机方法)07-1409:40:49.042:错误/AndroidRuntime(24098):在java.lang.reflect.Method.invoke(Method.java:507)07-14 09:40:49.042:错误/AndroidRuntime(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-1409:40:49.042:错误/AndroidRuntime(24098):在dalvik.system.NativeStart.main(本机方法)

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)

我该如何解决?谢谢!

推荐答案

发生错误是因为 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.

这篇关于java.lang.IllegalStateException:从第0行的字段获取字段槽0失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆