开发者

android - SimpleAdapter + SectionIndexer

I'm trying to use SectionIndexer in ListView using a SimpleAdapter.

I h开发者_开发知识库ave about 30 elements in an array and the list is being built by considering every pair of the 30 elements except where each element in the pair is identical (i.e i == j).

So each item in the list contains two text views and a checkbox. just to explain how the textviews are structured:

row1: textview1: afternoon(...) textview2: at(....)

row2: textview1: afternoon(...) textview2: battery_charging(....)

row3: textview1: afternoon(...)

etc etc

so basically every first TextView is the same until all pairs with that TextView have been consumed.

Since this list contains approximately 900(870 to be precise) entries I tried to implement SectionIndexing with FastScrolling.

While I understand how to do both, I seem to be running into a problem which I can't explain.

It looks like that when I scroll, the overlay that displays the current letter is always one ahead of the current position in the list.

I'm trying to work my head around this but I don't understand why.

I can post code, but I'm fairly sure I am not doing anything wrong.

The only flaw I can think of with this is the fact that all the words that begin with the same letter are identical.

thanks


it turned out I had to use this

 for (int i = size - 1; i >= 0; i--)

as opposed to

for (int i = 0; i<size; i++)

when I was creating the indexer map.

Just for the sake of interest, the reason the second for loop doesn't work is because each letter in the map is mapped to the last index of that letter.

Instead each letter has to map to the index when it first occurs. so for A it would be 0 and not 30 (where 30 is the number of items that start with A).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜