Skip to content
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

[Chip] Request: add ability to set chip as checked/unchecked but not by the user #4143

Open
AndroidDeveloperLB opened this issue Apr 12, 2024 · 0 comments

Comments

@AndroidDeveloperLB
Copy link

AndroidDeveloperLB commented Apr 12, 2024

Is your feature request related to a problem? Please describe.
In some cases, I want to be able to let the user press the Chip, but not to let it be toggled of being checked/unchecked due to it.
I want to decide when to have it be checked, and by which event (which might not be clicking on it, for example).

Describe the solution you'd like
Maybe have function "setCheckableByUser", and so in this case I would pass "false" to it.

Describe alternatives you've considered
I tried to use this:

chip.isCheckable=false
chip.isChecked = true

But it didn't let me check the chip.
And, using setOnClickListener when isCheckable is true means that the value I get is the new one, after it was toggled.

It could also be nice to be able to set a chip as checked/unchecked without triggering the setOnCheckedChangeListener.
Currently in order to do it, I will probably have to extend Chip and have the same thing I had to do here:
https://stackoverflow.com/a/27391245/878126

Additional context
https://developer.android.com/reference/com/google/android/material/chip/Chip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants