Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FastScrollBar go out of screen, when SectionIndexer implemented

I do ListView with custom adapter which implement SectionIndexer. When I type only minSdkVersion = 8 in Manifest file, all works fine. But if I add targetSdkVersion = 11 (or more) to Manifest, fast scrollbar starts roll out of screen when I scrolling the list, but there is not the end of the list.

And one more moment: if I add targetSdkVersion = 11 to manifest and do list adapter without SectionIndexer implementing, scrollbar works fine too.

But i need targetSdkVersion = 11 or more, and need SectionIndexer implement.

Any ideas?

like image 475
user1603329 Avatar asked Dec 06 '22 12:12

user1603329


1 Answers

My guess is it's because you didn't correctly implement getSectionForPosition(int position) method.

This is whet I do:

    @Override
    public int getSectionForPosition(int position) {
        for(int i = sections.length - 1; i >= 0; i--) {
            if(position > alphaIndexer.get(sections[i]))
                return i;
        }
        return 0;
    }
like image 182
ePeace Avatar answered May 01 '23 07:05

ePeace