2012-03-29 11 views
0

SimpleCursorAdapterの実装を使用しています。これはSectionIndexerを実装しています。ここにその一部があります:SimpleCursorAdapter.getView()のカーソルからデータを取得

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

内部でgetView(位置)その位置のカーソルからデータにアクセスする必要があります。どうすればいいのですか?

UPD

私はthisチュートリアルを使用しています。

答えて

8

はこれを試してみてください。

@Override 
public View getView(int position, View convertView, ViewGroup parent) 
{ 
    ... 
    Cursor cursor = (Cursor) getItem(position); 
} 
+0

カーソルがこのコールの後にNULLです。 –

+0

getItemを実装する理由はありますか?それを削除し、スーパークラスにそれを手に入れさせる – dldnh

関連する問題