androidxamarinxamarin.androidsectionindexer

Last section of SectionIndexer scrolls really fast


Here's a short video of my problem. The last section of the list is scrolling really fast, as you can see by the scrollbar. Here's my code (the relevant parts):

public TotemAdapter (Activity activity, List<Totem> list) { 
        _activity = activity;
        totemList = list;
        showDelete = false;

        var items = list.ToArray ();

        alphaIndex = new Dictionary<string, int>();
        for (int i = 0; i < items.Length; i++) {
            var key = items[i].title[0].ToString();
            if (!alphaIndex.ContainsKey(key)) 
                alphaIndex.Add(key, i);
        }
        sections = new string[alphaIndex.Keys.Count];
        alphaIndex.Keys.CopyTo(sections, 0);
        sectionsObjects = new Java.Lang.Object[sections.Length];
        for (int i = 0; i < sections.Length; i++) {
            sectionsObjects[i] = new Java.Lang.String(sections[i]);
        }
    }

public int GetPositionForSection (int section) {
        return alphaIndex[sections[section]];
    }

    public int GetSectionForPosition(int position) {
        return 1;
    }

    public Java.Lang.Object[] GetSections () {
        return sectionsObjects;
    }

Does anyone know how I can fix this?

Thanks in advance.


Solution

  • I fixed it by returning 0 instead of 1 in GetSectionForPosition.