views:

31

answers:

1

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.

A: 

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

Falmarri
They aren't defined at all. They never have been. This was all working fine before until I started using startManagingCursor (because I was receiving "Finalizing a Cursor that has not been deactivated or closed" errors). I also don't see how those two methods would affect this. I'm asking Android for the first and last visible positions; not for the data.
Andrew
Yeah, and I'm sure that getLastPosition() uses those 2 methods to determine that information
Falmarri
Why would it? Also, since I'm not overriding these methods, why would everything work fine when I dont startManagingCursor, but fail once I do? In both cases, I have not overrode these methods
Andrew