I’m encountering an issue with accessibility in a RecyclerView when using RecyclerViewAccessibilityDelegate
. The onInitializeAccessibilityNodeInfo
method is successfully called for the RecyclerView itself, but not for its ItemDelegate
. This means that individual items are not getting their accessibility node info initialized.
This issue occurs only when I activate TalkBack using the accessibility shortcut after navigating to the screen. If TalkBack is already enabled before entering the screen, everything works as expected.
recyclerView.setAccessibilityDelegateCompat(object : RecyclerViewAccessibilityDelegate(recyclerView) {
override fun getItemDelegate(): ItemDelegate {
return object : ItemDelegate(this) {
override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(host, info)
info.contentDescription = "Item description: $host"
}
}
}
})