@Override
    protected int[] onCreateDrawableState(int extraSpace) {
        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
        if (mChecked) {
            mergeDrawableStates(drawableState, CHECKED_STATE_LIST);
        }
        return drawableState;
    }
A checkable button which has two states (selected and unselected)

@author liangfeizc
sample/src/main/java/com/liangfeizc/flowlayout/sample/CheckableButton.java