0

我想用 CursorAdapter 和 Alphabet 标题实现 Material Style ListView,如下面的链接所示。 https://s3.amazonaws.com/uploads.hipchat.com/67537/1095843/8h5VtFvLlRMOsqI/2015-08-19%20at%209.28%20AM.png

字母缩写只是我列表视图的 layout_item 中的一个文本视图。如何确定何时设置字母表。它看起来很简单,但由于它是一个光标适配器,我看到当我上下滚动时,这个 textView 值不断变化/消失。请注意:我使用的是游标适配器,因此数据是逐行出现的。我无权一次将所有数据发送到适配器以将所有内容放入地图并为其编制索引。有没有人做过类似的事情?Java中是否有我可以使用的类。

private String sectionName = "";
public void bindView(View convertView, Context context, Cursor cursor) {
    if (!newSectionName.equals(sectionName)) {
        holder.txtSectionName.setText(newSectionName);
        sectionName = newSectionName;
    } else {
        holder.txtSectionName.setText("");
    }
}
4

1 回答 1

0

首先你应该研究一下RecyclerView材料设计支持库谷歌出来了。这两个资源将帮助您入门。滚动气泡本质上是一个 onScroll 事件,它获取用户的位置并基于该位置(以及他们滚动的量)超过在该气泡中显示的字母的设定阈值。

https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html

http://android-developers.blogspot.com/2015/05/android-design-support-library.html

于 2015-08-20T20:04:00.817 回答