I've chip group that I want to disable when some operation happen.
Currently my code look like this:
R.id.all -> {
chipGroup.clearCheck()
chipGroup.isClickable = false
selectedCategory = null
}
It does clear all the checks, but I still can click and select chips.
How can I prevent all the chips from being clicked?
Chips are compact elements that represent an attribute, text, entity, or action. They allow users to enter information, select a choice, filter content, or trigger an action.
A ChipGroup is used to hold multiple Chip s. By default, the chips are reflowed across multiple lines. Set the app:singleLine attribute to constrain the chips to a single horizontal line. If you do so, you'll usually want to wrap this ChipGroup in a HorizontalScrollView .
This Kotlin Extension Function allows you to enable/disable all Chips within the Chip Group:
fun ChipGroup.setChildrenEnabled(enable: Boolean) {
children.forEach { it.isEnabled = enable }
}
You can use it like this:
chipGroup.setChildrenEnabled(false)
public void setChipEnable(boolean status) {
for (int i = 0; i < chipGrp.getChildCount(); i++) {
chipGrp.getChildAt(i).setEnabled(status);
}
}
setChipEnable(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With