AlphabetIndexer with Custom Adapter

前端 未结 2 456
谎友^
谎友^ 2020-12-08 23:41

Can someone show me an example of how to use AlphabetIndexer with a Custom Adapter that uses a getView? I have it working with a standard adapter,

2条回答
  •  悲哀的现实
    2020-12-09 00:38

    If you're using a LoaderManager to manage your adapter's cursor, you'll want to make a small adjustment and override your adapters swapCursor method:

    public Cursor swapCursor(Cursor c) {
        // Create our indexer
        if (c != null) {
            mIndexer = new AlphabetIndexer(c, c.getColumnIndex(Books.TITLE),
                    " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
         }
         return super.swapCursor(c);
     }
    

    Everything else remains just as @vsm describes.

提交回复
热议问题