후~ 전편은 여기로!
2012/03/07 - [Android Study] - Android Study ListView Indexer 2편 

아흥 슬슬 어케 마무리 지어야 할지 매우 난감하네...
private class IconAdapter extends CursorAdapter implements SectionIndexer {
    private SectionIndexer mIndexer;
    
@Override
    public int getPositionForSection(int sectionIndex) {
        if (mIndexer == null) {
            return -1;
        }
        return mIndexer.getPositionForSection(sectionIndex);
    }
 
    @Override
    public int getSectionForPosition(int position) {
        if (mIndexer == null) {
            return -1;
        }
        return mIndexer.getSectionForPosition(position);
    }

    @Override
    public Object [] getSections() {
        if (mIndexer == null) {
            // 이거 null 리턴하면 200% 에러 발생함. 그냥 요롷게 주는게 속편함.
            return new String[] { " " };
        } else {
            return mIndexer.getSections();
        }
    } 
}
정말 별거 없는 내용임... 그냥 mIndexer 객체가 null 일 경우만 정해 주면 알아서 처리가 됨. 참 쉽죠잉~ 
다음 편은 PracticeIndexer class 내용 입니당~

'Android' 카테고리의 다른 글

Android Study ListView Indexer 5편  (0) 2012.03.07
Android Study ListView Indexer 4편  (0) 2012.03.07
Android Study ListView Indexer 2편  (1) 2012.03.07
Android Study ListView Indexer 1편  (0) 2012.03.07
LayoutInflater에 대하여...  (0) 2012.02.15

+ Recent posts