Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7615921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:45:44+00:00 2026-05-31T02:45:44+00:00

So I have one activity with a listview in it that is dynamically updated

  • 0

So I have one activity with a listview in it that is dynamically updated via cursors. The cursor object is being reused by simply reassigning a query command to this variable, which returns a whole new set of data. This works fine. The issue is that I have extended SimpleCursorAdapter to work with an AlphaIndexer. Apparently when the cursor is updated or changed, its supposed to clear the indexed cache. This is not happening. The main reason for all of this is to have fast scroll working on different cursors that are passed in and have it work. Right now, in using different cursors, the listview is using indexes from the first listview with trying to fastscroll through the second listview.

class AlphaCursor extends SimpleCursorAdapter implements SectionIndexer {

    AlphabetIndexer alphaIndexer;
    private int list_type;
    public AlphaCursor(Context context, int layout, Cursor c, String[] from, int[] to, int type, String sortBy) {
        super(context, layout, c, from, to);
        // MUST have space in front of alphabet
        int count = c.getCount();
        // this.onContentChanged();doesnt do a thing
        alphaIndexer = new AlphabetIndexer(c, c.getColumnIndex(sortBy), " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        list_type = type;

Any idea what might be going on or how to clear this cache? I tried onChanged() as well as onContentChanged(). Has anyone seen this or know any suggestions?

The code is being used like such:

    alpha = new AlphaCursor(ClassActivity.this, R.layout.list_item, m_cursor, from, to, TAB_HOME, "name");
    alpha.changeCursor(m_cursor);
mList.setAdapter(alpha);

Keep in mind, I have 4 ‘tabs’ that just requery a cursor and create a new AlphaIndexer. Each time a tab is clicked, the alpha variable is nulled out. It looks like there is view cahcing with the indexer.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:45:46+00:00Added an answer on May 31, 2026 at 2:45 am

    Since it seems that the AlphaIndexer becomes tied to the ScrollView when it’s first used, it ignores any subsequent changes when a new one is set in the Adapter.

    To get around the problem as described in the question, I made the AlphaIndexer a member of the ListFragment and created it once. On subsequent changes to the cursor used in the adapter, I just called alphaIndexer.setCursor(aCursor). This fixed the ‘stale’ index problem and also the ‘offset’ alphabet when trying to use setFastScrollEnabled() with false/true.

    I assume that this will also work with a ListActivity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Activity that uses a ListView to simply display a list of
In one of my Activities I have a ListView that displays a list of
I have an activity that shows customer information. All the controls are drawn dynamically
My activity implements OnTouchListener and it have one ListView inside it. When user touch
I have an activity with a listview that is displaying the results of a
I have created a custom listview that have one webview per element. My problem
I have an activity with ListView that has: android:theme=@android:style/Theme.Dialog in Manifest. When I open
I have a custom ListView activity that maintains a state array (3 choices, default=black,
I have one activity/java file (Browsefile.java) that would obtain the absolute path of the
I have one activity A, that has one button and one list view which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.