Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@msdx
Created September 19, 2016 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msdx/b4daff2dc8f58d51faafff96a915ed96 to your computer and use it in GitHub Desktop.
Save msdx/b4daff2dc8f58d51faafff96a915ed96 to your computer and use it in GitHub Desktop.
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