I'm trying to implement a fast scroller with AlphabetIndexer, but when
the cursor changes, its not refreshing the index chache. In my
CursorAdapter constructor I call setCursor(cursor) but nothing
changes, and acording to the documentation:

"Your adapter is responsible for updating the cursor by calling
setCursor(Cursor) if the cursor changes. getPositionForSection(int)
method does the binary search for the starting index of a given
section (alphabet)."

But nothing is happening. I'm using this for a search filter, so when
I search contacts, it updates the list with the contacts, so
AlphabetIndexer should work for update the index of the new items in
the list.

Example: My whole list starts with contacts that starts with 'A' and
ends with contacts that starts with 'E'. So the AlphabetIndexer will
have this indexes in its cache.

But, lets try to search contacts with 'C', and lets say I have 250
contacts that starts with 'C'. So, I have to fast scroll through this
contacts, and the 'C' index must show, but instead of only 'C' it
shows all indexes, that were shown when I had the entire list.

Here is my CursorAdapter constructor where I call setCursor(cursor)
for every letter I type:

public MyCursorAdapter(Context context, Cursor cursor,
ArrayList<Integer> ids)
        {
            super(context, cursor);
            try
            {
                mAlphaIndexer = new AlphabetIndexer(cursor,
cursor.getColumnIndexOrThrow("Name")," ABCDEFGHIJKLMNOPQRSTUVWXYZ");
                notifyDataSetChanged();
                mAlphaIndexer.setCursor(cursor);
                this.mSelectedContacts = ids;
                Log.e("MyCursorAdapter", "construtor: ");
            }
            catch(Exception ex)
            {
                Log.e("MyCursorAdapter", "Error: " + ex);
            }
            finally
            {
                mAlphaIndexer.setCursor(cursor);
            }
        }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to