0

我的主要活动中有一个列表视图,当我们单击它时显示一个人的详细信息,我有两个类

EmployeeList.java - http://pastebin.com/5vPMKrCQ

DatabaseHelper.java - http://pastebin.com/NS7RR8E6

我的 logcat 中有以下异常。

05-09 16:58:10.278: E/CursorWindow(23310): Failed to read row 0, column -1 from a CursorWindow which has 2 rows, 3 columns.


05-09 16:58:10.368: E/AndroidRuntime(23310): java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
4

3 回答 3

1
Cursor cursor = db.rawQuery("select * from employee_directory where _id " + id);

    if (null != cursor&&cursor.moveToFirst()) {

            String title= cursor.getString(cursor.getColumnIndex(DatabaseHelper.TITLE));

            String membername= currsor.getString(cursor.getColumnIndex(DatabaseHelper.MEMBER_NAME));

        }
于 2012-05-09T12:14:14.730 回答
0

可能是您在从数据库中将值放入游标后还没有完成cursor.moveToFirst() 。

于 2012-05-09T12:04:17.237 回答
0

试试下面的代码

    setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

                    @Override
                    public boolean onItemLongClick(AdapterView<?> parent, View v,
                            int position, long id) {
//Your logic
                    }
                }
于 2012-05-09T12:08:25.427 回答