I have a group of FrameLayout
which I want to be checkable/selectable,
That is, after a click I would like the FrameLayout
to display as
Adding the following code to a Checkable
class allows Selectors to work:
private static final int[] CheckedStateSet = {
android.R.attr.state_checked,
};
@Override
protected int[] onCreateDrawableState(int extraSpace) {
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
if (isChecked()) {
mergeDrawableStates(drawableState, CheckedStateSet);
}
return drawableState;
}
@Override
public boolean performClick() {
toggle();
return super.performClick();
}