Code example for TypedArray

Methods: getInteger

0
 
    @Override 
    protected Object onGetDefaultValue(TypedArray a, int index) {
        // This preference type's value type is Integer, so we read the default 
        // value from the attributes as an Integer. 
        return a.getInteger(index, 0);
    } 
 
    @Override 
    protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
        if (restoreValue) {
            // Restore state 
            mClickCounter = getPersistedInt(mClickCounter);
        } else { 
            // Set state 
            int value = (Integer) defaultValue;
            mClickCounter = value;
            persistInt(value);
        } 
    }