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

setOnClickListener getting callback twice #31

Closed
amankumar367 opened this issue Jan 25, 2022 · 0 comments
Closed

setOnClickListener getting callback twice #31

amankumar367 opened this issue Jan 25, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@amankumar367
Copy link
Contributor

I have some requirements where some buttons will be disabled but onClick of that button show toast message.
When trying to add setOnClickListener on the disabled button, I was getting toast twice.

To Reproduce

val btn2 = ThemedButton(buttonGroup.context)
btn2.text = "Button 2"
btn2.isEnabled = false
buttonGroup.addView(btn2, ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT))


buttonGroup.buttons.forEach { button ->
      if (button.isEnabled.not()) {
            button.setOnClickListener { showToast("${btn2.text} clicked") }
      }
}
@amankumar367 amankumar367 added the bug Something isn't working label Jan 25, 2022
@Bryanx Bryanx closed this as completed in 7ba0640 Jan 29, 2022
Bryanx added a commit that referenced this issue Jan 29, 2022
(fixes: #31) setOnClickListener getting callback twice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant