而滚动AlphabetIndexer快速滚动滑块消失 [英] Fast scroll thumb disappears while scrolling AlphabetIndexer

查看:139
本文介绍了而滚动AlphabetIndexer快速滚动滑块消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的ListView fastScrollAlwaysVisible fastScrollEnabled 无论设置为。实施 SectionIndexer 我的适配器 AlphabetIndexer 之后,我快速滚动滑块将消失,而我滚动,然后重新出现,一旦我到了列表的顶部或底部。我是pretty的茫然不知为什么发生这种情况。我以前没有经历过。

下面的一切工作就 AlphabetIndexer 关注。我的问题是,为什么我的快速滚动滑块消失,而我滚动,我怎么可以消失阻止它?

无论是否快速滚动总是的可见无所谓。每当快速滚动可见,在快速滚动滑块是不存在的,它只是消失了,这是我的问题。此外,当我删除 AlphabetIndexer 快速滚动滑块就像我打算为它。一切成功的作品在活动,但是当我打开我的的ListView 片段的东西最终会像我解释。

这是我的适配器我的的ListView

 私有类AlbumsAdapter扩展SimpleCursorAdapter工具
        SectionIndexer {

私人AlphabetIndexer mIndexer;

//我要重写这一点,因为我使用的是'LoaderManager`
@覆盖
    公共光标swapCursor(光标指针){

        如果(光标!= NULL){
            mIndexer =新MusicAlphabetIndexer(光标,mAlbumIdx,
                    。getResources()的getString(R.string.fast_scroll_alphabet));
        }
        返回super.swapCursor(光标);
    }

    @覆盖
    公共对象[] getSections(){
        返回mIndexer.getSections();
    }

    @覆盖
    公众诠释getPositionForSection(INT部分){
        返回mIndexer.getPositionForSection(部分);
    }

    @覆盖
    公众诠释getSectionForPosition(INT位置){
        返回0;
    }
}
 

MusicAlphabetIndexer 正确帮助理清音乐:

 类MusicAlphabetIndexer扩展AlphabetIndexer {

公共MusicAlphabetIndexer(光标指针,整数sortedColumnIndex,
        CharSequence的字母){
    超(光标,sortedColumnIndex,字母);
}

@覆盖
保护INT比较(串词,串字母){
    字符串wordKey = MediaStore.Audio.keyFor(字);
    字符串letterKey = MediaStore.Audio.keyFor(函);
    如果(wordKey.startsWith(字母)){
        返回0;
    } 其他 {
        返回wordKey.compareTo(letterKey);
    }
  }
}
 

解决方案

我和快速滚动的拇指图标类似的问题。我研究Android源$ C ​​$ C,发现提交其介绍这个问题和其他(ArrayIndexOutOfBoundsException异常)。我建连Android系统没有这个承诺,它的工作呢。

我在6月提交的问题:<一href="https://$c$c.google.com/p/android/issues/detail?id=33293">https://$c$c.google.com/p/android/issues/detail?id=33293
当我读它知道我看到我能更好地描述这个问题:)

这是提交其制作的问题:<一href="https://github.com/android/platform_frameworks_base/commit/32c3a6929af9d63de3bf45a61be6e1a4bde136d3">https://github.com/android/platform_frameworks_base/commit/32c3a6929af9d63de3bf45a61be6e1a4bde136d3

不幸的是我没有找到任何解决方案,除了撤销这些承诺,而我离开它。
我希望有人会找到如何解决它。

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);
    }
  }
}

解决方案

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.

这篇关于而滚动AlphabetIndexer快速滚动滑块消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆