Skip to content

Instantly share code, notes, and snippets.

@akexorcist
Created February 23, 2023 09:00
Show Gist options
  • Save akexorcist/ff5a33f0921ac84a350a4b92fc0c25a0 to your computer and use it in GitHub Desktop.
Save akexorcist/ff5a33f0921ac84a350a4b92fc0c25a0 to your computer and use it in GitHub Desktop.
Prevent accessibility action in Android views
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