我正在使用实现的SimpleCursorAdapter实现SectionIndexer.这是它的一部分:
public class MyAlphabetizedAdapter extends SimpleCursorAdapter implements
SectionIndexer {
public ContactAlphabetizedAdapter(Context context, int layout,
Cursor cursor, String[] from, int[] to) {
mIndexer = new AlphabetIndexer(cursor, cursor.getColumnIndexOrThrow(ContactsContract.Data.DISPLAY_NAME), sAlphabet);
}
@Override
public Object getItem(int position) {
if (getItemViewType(position) == TYPE_NORMAL) {
return super
.getItem(position
- mSectionToOffset
.get(getSectionForPosition(position)) - 1);
}
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
在getView(位置)里面我需要从光标访问该位置的数据.我该怎么做?
UPD
我正在使用本教程.
试试这个:
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
...
Cursor cursor = (Cursor) getItem(position);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3148 次 |
| 最近记录: |