I try to write my own CheckBox
using RelativeLayout
with TextView
and FrameLayout
(with selector on background) inside.>
Nik's answer is partially right for me, you need added android.R.attr.state_checkable into the STATE_CHECKABLE array, and set the corresponding lenth (2), or else it fails to work.
private static final int[] CHECKED_STATE_SET = {android.R.attr.state_checked, android.R.attr.state_checkable};
@Override
protected int[] onCreateDrawableState(int extraSpace)
{
int[] result = super.onCreateDrawableState(extraSpace + CHECKED_STATE_SET.length);
if(mChecked) mergeDrawableStates(result, CHECKED_STATE_SET);
return result;
}