New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable the segmented control #7
Comments
You want to disable segment selection, right ? |
If it's true, than here is the example how to disable segment... segmentedControl.addOnSegmentSelectListener(new OnSegmentSelectedListener<String>() {
@Override
public void onSegmentSelected(SegmentViewHolder<String> segmentViewHolder, boolean isSelected, boolean isReselected) {
if (segmentViewHolder.getAbsolutePosition() == 3){ // disable segment 3
segmentViewHolder.onSegmentSelected(false,false);
}
}
}); |
Disable all segments segmentedControl.addOnSegmentSelectListener(new OnSegmentSelectedListener<String>() {
@Override
public void onSegmentSelected(SegmentViewHolder<String> segmentViewHolder, boolean isSelected, boolean isReselected) {
segmentViewHolder.onSegmentSelected(false,false);
}
}); |
Let me close the issue, but fill free to reopen it, if you have any questions |
That doesn't solve the problem as view is still clickable. What if you would like to disable possibility of clicking any segment and keep selection as it was before disabling segmentedControl? |
Call this function to disable public static void disableSegmentedControl(View view) {
if ((view != null)) {
view.setClickable(false);
view.setLongClickable(false);
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
View innerView = ((ViewGroup) view).getChildAt(i);
disableSegmentedControl(innerView);
}
}
} |
I disabled the segment by
setEnable(false)
but it doesn't workSo I used the following code but it is better to make disable feature
The text was updated successfully, but these errors were encountered: