Code example for SimpleCursorAdapter

Methods: getItemId, hasStableIds, notifyDataSetChanged

0
        } 
         
        if (mChoiceMode == CHOICE_MODE_MULTIPLE) {
            boolean oldValue = mCheckStates.get(position);
            mCheckStates.put(position, value);
            if (mCheckedIdStates != null && hasStableIds()) {
                if (value) {
                    mCheckedIdStates.put(getItemId(position), position);
                } else { 
                    mCheckedIdStates.delete(getItemId(position));
                } 
            } 
            if (oldValue != value) {
                if (value) {
                    mCheckedItemCount++;
                } else { 
                    mCheckedItemCount--;
                } 
            } 
            if (mMultipleChecksListener != null) {
                final long id = getItemId(position);
                mMultipleChecksListener.onCheckedStateChanged(this,
                        position, id, value);
            } 
        } else { 
            boolean updateIds = mCheckedIdStates != null && hasStableIds();
            // Clear all values if we're checking something, or unchecking the currently 
            // selected item 
            if (value || isItemChecked(position)) {
                mCheckStates.clear();
                if (updateIds) {
                    mCheckedIdStates.clear();
                } 
            } 
            // this may end up selecting the value we just cleared but this way 
            // we ensure length of mCheckStates is 1, a fact getCheckedItemPosition relies on 
            if (value) {
                mCheckStates.put(position, true);
                if (updateIds) {
                    mCheckedIdStates.put(getItemId(position), position);
                } 
                mCheckedItemCount = 1;
            } else if (mCheckStates.size() == 0 || !mCheckStates.valueAt(0)) {
                mCheckedItemCount = 0;
            } 
        } 
 
        notifyDataSetChanged();
    } 
 
    /** 
     * Defines the choice behavior for the List. By default, Lists do not have any choice behavior 
     * ({@link #CHOICE_MODE_NONE}). By setting the choiceMode to {@link #CHOICE_MODE_SINGLE}, the