Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast scroll thumb disappears while scrolling AlphabetIndexer

I have a ListView with fastScrollAlwaysVisible and fastScrollEnabled both set to true. After implementing SectionIndexer to my Adapter and an AlphabetIndexer, my fast scroll thumb will disappear while I scroll, then reappear once I reach the top or bottom of the list. I'm pretty clueless about why this happens. I haven't experienced it before.

Everything below works as far as AlphabetIndexer is concerned. My question is why does my fast scroll thumb disappear while I scroll and how can I stop it from disappearing?

Whether or not the fast scroll is always visible doesn't matter. Whenever the fast scroll is visible, the fast scroll thumb is not there, it's simply gone and that's my problem. Also, when I remove the AlphabetIndexer the fast scroll thumb works like I intend for it to. Everything works successfully in an Activity, but when I load my ListView in a Fragment things end up like I explain.

This is my Adapter for my ListView:

private class AlbumsAdapter extends SimpleCursorAdapter implements         SectionIndexer {  private AlphabetIndexer mIndexer;  // I have to override this because I'm using a `LoaderManager` @Override     public Cursor swapCursor(Cursor cursor) {          if (cursor != null) {             mIndexer = new MusicAlphabetIndexer(cursor, mAlbumIdx,                     getResources().getString(R.string.fast_scroll_alphabet));         }         return super.swapCursor(cursor);     }      @Override     public Object[] getSections() {         return mIndexer.getSections();     }      @Override     public int getPositionForSection(int section) {         return mIndexer.getPositionForSection(section);     }      @Override     public int getSectionForPosition(int position) {         return 0;     } } 

MusicAlphabetIndexer helps sort through music correctly:

class MusicAlphabetIndexer extends AlphabetIndexer {  public MusicAlphabetIndexer(Cursor cursor, int sortedColumnIndex,         CharSequence alphabet) {     super(cursor, sortedColumnIndex, alphabet); }  @Override protected int compare(String word, String letter) {     String wordKey = MediaStore.Audio.keyFor(word);     String letterKey = MediaStore.Audio.keyFor(letter);     if (wordKey.startsWith(letter)) {         return 0;     } else {         return wordKey.compareTo(letterKey);     }   } } 
like image 226
adneal Avatar asked Mar 20 '12 02:03

adneal


2 Answers

I had similar issue with fast scroller's thumb icon. I was investigating Android source code and found a commit which introduced this problem and other (ArrayIndexOutOfBoundsException). I built even Android system without this commit and it worked then.

I submitted the issue in June: https://code.google.com/p/android/issues/detail?id=33293
When I'm reading it know I see I could describe the issue better :)

This is the commit which is making problems: https://github.com/android/platform_frameworks_base/commit/32c3a6929af9d63de3bf45a61be6e1a4bde136d3

Unfortunately I haven't found any solution, except revert the commit, and I left it.
I hope someone will find how to fix it.

like image 157
pawelzieba Avatar answered Oct 05 '22 18:10

pawelzieba


Do you have both fastScrollEnabled and fastScrollAlwaysVisible set to true? There is no fastScrollAlwaysEnabled attribute of a ListView, so I'm thinking maybe you just have fastScrollEnabled set to true but fastScrollAlwaysVisible is set to its default value, which is false.

like image 30
Brian Cooley Avatar answered Oct 05 '22 19:10

Brian Cooley