带自定义适配器的AlphabetIndexer [英] AlphabetIndexer with Custom Adapter

查看:129
本文介绍了带自定义适配器的AlphabetIndexer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我展示如何将 AlphabetIndexer 与使用 getView 的自定义适配器一起使用的示例吗?我可以在标准适配器上使用它,但是不知道如何在自定义适配器上实现它。

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, but have no clue how to implement it with a custom adapter.

谢谢

推荐答案

如果您使用LoaderManager来管理适配器的游标,则需要进行一些小的调整并覆盖适配器的swapCursor方法:

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);
 }

其他所有内容均与@vsm所述相同。

Everything else remains just as @vsm describes.

这篇关于带自定义适配器的AlphabetIndexer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆