Search code examples
androidaccessibilitytalkback

Talk Back annoucing spinner content description even when editText has focus


I have a Layout, that has a form .. about five items down in the form is a spinner, and everytime my activity loads Talkback seems to read this spinners content description even though the focus and flashing cursor are on the first edittext view.

I can't seem to stop it.. any ideas?


Solution

  • Accessibility Focus and Input Focus are tracked separately in Android. I would need more details about your specific scenario to provide a 100% answer. However, my guess is that your EditText field is requesting input focus when the view loads, so the cursor is being moved there, and potentially the keyboard is popped up (depending on Android version). However, due to tab ordering, or some other mechanism, the spinner is the first item on the page to get Accessibility Focus.

    There are two solutions to this, depending on the behavior that you want.

    Solution 1 (recommended): Don't have your EditText box request input focus. Allow the user to force input focus into the box on interaction. For capable users, this is just a simple tap into the EditText box.

    Solution 2 (less accessibile, but perhaps more usable): Shift accessibility focus to the EditText in your onResume method (or onCreate, or wherever you deem most appropriate). A method like this would be best:

    public void resetFocus() {        
        editTextControl.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
        editTextControl.requestFocus();
    }
    

    I would recommend calling the above method in onResume, so that every time this particular view loads input and accessibility focus will be in a predictable place. Otherwise, you've created additional accessibility issues.