POJO CLASS GridItem:
public class GridItem {
int id;
String path;
String name;
String chr;
int headerId;
public GridItem(String path, String name, String chr){
this.path = path;
this.name = name;
this.chr = chr;
}
}
活动:
ArrayList<GridItem> books = new ArrayList<GridItem>();
现在我想将这个arraylist转换为光标,使sectionindexer成为gridview。所以我在下面的代码中使用该光标:
static class YOUR_ADAPTER extends SimpleCursorAdapter implements SectionIndexer {
private AlphabetIndexer mIndexer;
YOUR_ADAPTER (Context context, AlbumBrowserActivity currentactivity,
int layout, Cursor cursor, String[] from, int[] to) {
super(context, layout, cursor, from, to);
getColumnIndices(cursor);
}
private void getColumnIndices(Cursor cursor) {
if (cursor != null) {
YOUR_COLUMN = cursor.getColumnIndexOrThrow(WHAT_YOU'RE_SORTING);
if (mIndexer != null) {
mIndexer.setCursor(cursor);
} else {
mIndexer = new AlphabetIndexer(cursor, YOUR_COLUMN, mResources.getString(
R.string.fast_scroll_alphabet));
}
}
}
public Object[] getSections() {
return mIndexer.getSections();
}
public int getPositionForSection(int section) {
return mIndexer.getPositionForSection(section);
}
public int getSectionForPosition(int position) {
return 0;
}
}
如果有人有解决方案,那么在这里公开..