滚动 AlphabetIndexer 时快速滚动拇指消失 [英] Fast scroll thumb disappears while scrolling AlphabetIndexer
问题描述
我有一个 ListView
,其中 fastScrollAlwaysVisible
和 fastScrollEnabled
都设置为 true
.在将 SectionIndexer
实施到我的 Adapter
和一个 AlphabetIndexer
之后,我的 fast scroll thumb
将在我滚动时消失,然后重新出现一旦我到达列表的顶部或底部.我对为什么会发生这种情况一无所知.我以前没有经历过.
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.
就 AlphabetIndexer
而言,下面的一切都有效.我的问题是为什么我的快速滚动拇指在滚动时消失了,我该如何阻止它消失?
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?
fast scroll
是否始终可见并不重要.每当 fast scroll
可见时,fast scroll thumb
都不在那里,它只是消失了,这就是我的问题.此外,当我删除 AlphabetIndexer
时,fast scroll thumb
就像我想要的那样工作.一切都在 Activity
中成功运行,但是当我在 Fragment
中加载我的 ListView
时,事情最终就像我解释的那样.
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.
这是我的ListView
的Adapter
:
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
有助于正确分类音乐:
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);
}
}
}
推荐答案
我遇到了与快速滚动器的拇指图标类似的问题.我正在调查 Android 源代码并发现一个提交,它引入了这个问题和其他(ArrayIndexOutOfBoundsException).我什至在没有这个提交的情况下构建了 Android 系统,然后它就可以工作了.
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.
我在 6 月份提交了问题:https://code.google.com/p/android/issues/detail?id=33293
当我阅读它时,我知道我可以更好地描述问题:)
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 :)
这是造成问题的提交:https://github.com/android/platform_frameworks_base/commit/32c3a6635a3a3a64d6e/a>
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.
这篇关于滚动 AlphabetIndexer 时快速滚动拇指消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!