Created
September 19, 2016 04:15
-
-
Save msdx/b4daff2dc8f58d51faafff96a915ed96 to your computer and use it in GitHub Desktop.
ForceableChoiceLayout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 绑定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