Created
February 23, 2023 09:00
-
-
Save akexorcist/ff5a33f0921ac84a350a4b92fc0c25a0 to your computer and use it in GitHub Desktop.
Prevent accessibility action in Android views
This file contains 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
import android.core.view.AccessibilityDelegateCompat | |
import android.core.view.ViewCompat | |
val button: Button = /* ... */ | |
ViewCompat.setAccessibilityDelegate( | |
button, | |
object : AccessibilityDelegateCompat() { | |
override fun performAccessibilityAction(host: View?, action: Int, args: Bundle?): Boolean { | |
return false | |
} | |
} | |
) | |
button.setOnClickListener { | |
// Click event from user action only | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment