2

I have created a custom navigation line menu on Android TV that consists of a LinearLayoutCompat with AppCompatButtons that each represents an entry in the menu.

The menu is built dynamically, in the code at runtime by inflating the AppCompatButtons 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 ?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.