首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >[奇怪的问题]CursorIndexOutOfBoundsException:请求索引-1,大小为4

[奇怪的问题]CursorIndexOutOfBoundsException:请求索引-1,大小为4
EN

Stack Overflow用户
提问于 2011-08-24 09:09:03
回答 1查看 128关注 0票数 0

我有以下代码,当在地图中的标记上粘贴时,显示AlertDialog:

代码语言:javascript
复制
protected boolean onTap(int index) {
            db = openHelper.getWritableDatabase();

            String[] result_columns = new String[] {COL_DESCRI};

            Cursor cur = db.query(true, TABLE_COORD, result_columns,
             null, null, null, null, null, null);

            cur.moveToPosition(index-1);
                String description = cur.getString(cur.getColumnIndexOrThrow(COL_DESCRI));

                AlertDialog.Builder dialog = new AlertDialog.Builder(Geo.this);
                dialog.setTitle("Infos.");
                dialog.setMessage(description);
                dialog.setPositiveButton("OK", new OnClickListener() {    
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                dialog.show();



             cur.close();
             db.close();

            return true;
        }

问题是4的3个标记工作得很好,反之,还有一个强制关闭应用程序。这个错误会有什么问题呢?我做了cur.moveToPosition(index-1);,总是遇到同样的问题。谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2011-08-24 09:27:26

你试过使用cur.moveToNext()吗?对我来说很管用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7169373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档