Alex Rivera | Logout

getLastVisiblePosition returning -1

Asked 2010-10-27T19:00:21.020
15

I'm having a problem with my ListView (using CursorAdapter). When I call getListView().getLastVisiblePosition() I am receiving -1. This is a problem since my list is populated with items. Additionally, getListView().getFirstVisiblePosition() always returns 0, no matter where I am scrolled on the list. Any ideas?

It has something to do with startManagingCursor

    @Override
    public void changeCursor(Cursor cursor) {
        super.changeCursor(cursor);
        MyActivity.this.mCursor = cursor;
        //startManagingCursor(MyActivity.this.mCursor);
    }

If I comment out startManagingCursor, everything works fine. I've also tried adding stopManagingCursor() before changing the Cursor and still have the same problem.

Edit
Report

1 Answer

0

My guess is that your getItem(int position) and getItemId(int position) methods aren't defined correctly in your adapter.

answered 2010-10-27T19:04:55.347

Your Answer