Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ForceableChoiceLayout
/**
* 绑定Checkable控件的Layout.
*/
public static class ForceableChoiceLayout extends DefaultChoiceView {
/**
* 是否强制设为选中状态
*/
private boolean mForceChecked;
public ForceableChoiceLayout(Context context, View view) {
super(context, view);
}
@Override
public void setChecked(boolean checked) {
super.setChecked(checked | mForceChecked);
}
/**
* 是否为强制选中状态。
*
* @return 如果是强制选中状态返回true,否则返回false。
*/
public boolean isForceChecked() {
return mForceChecked;
}
/**
* 设置是否强制选中状态。
*
* @param forceChecked 是否强制选中状态。
*/
public void setForceChecked(boolean forceChecked) {
mForceChecked = forceChecked;
}
@Override
public void toggle() {
setChecked(mForceChecked | !isChecked());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.