Reputation: 3573
I have created a custom navigation line menu on Android TV that consists of a LinearLayoutCompat
with AppCompatButton
s that each represents an entry in the menu.
The menu is built dynamically, in the code at runtime by inflating the AppCompatButton
s and then manually insert them into the parent via addView(...)
.
Then I set the right order for Talkback in the code:
// after adding the views to the parent
menuItemsViews.forEachIndexed { index, menuItemView ->
if (index < (menuItemsViews.size - 1)) {
menuItemView.accessibilityTraversalBefore = menuItemsViews[index + 1].id
}
if (index > 0) {
menuItemView.accessibilityTraversalAfter = menuItemsViews[index -1].id
}
}
Note: I made sure to call generateViewId()
on each of these menuItemsViews
after constructing them.
Here is an example of a menu:
|HOME| |PROFILE| |SEARCH| |SETTINGS|
However it does not work: Talkback will never respect the order and choose "Profile" instead of "Home".
To ensure I have properly defined the accessibilityTraversalBefore|After
, I have set an accessibilityDelegate
in the parent LinearLayoutCompat
and overriden onRequestSendAccessibilityEvent
to place a breakpoint => everything is correct.
Why does it ignore the order I have defined ?
Upvotes: 1
Views: 490