我想用 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("");
}
}