Using section indexes

Even if we have enabled fast scroll, it is still difficult to know where we are in the list. To get around this, we make use of section indexes.

How to do it...

Making a list show a section index popup while scrolling is quite easy, requiring only that the adapter implements the ISectionIndexer interface. Let's take a look at the following steps:

  1. In order to enable the section index, we need to ensure that fast scroll is enabled on the list view:
    listView.FastScrollEnabled = true;
  2. Then we ensure that the list adapter implements the ISectionIndexer interface:
    public class PeopleAdapter :
      BaseAdapter<Person>, ISectionIndexer { public int GetPositionForSection(int section) { } public int GetSectionForPosition(int position) { } public ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.