In Accessibility Mode, I Want To Override The TalkBack For A TextView
I currently have a ListView and each element of t开发者_运维知识库hat list consists of at least two TextViews. I'm adding accessibility to my app, so whenever I focus on a certain list element, it reads out the text in each TextView.
Right now, I'm sending it a TalkBack event, but right after it completes it, it reads out the TextViews again. I want it to only complete my TalkBack event and nothing else.
Anyone have a clue how to do this?
Thanks in advance!
Sure, just override View.dispatchPopulateAccessibilityEvent.
From the doc (emphasis mine):
A typical implementation will call onPopulateAccessibilityEvent(AccessibilityEvent) on the this view and then call the dispatchPopulateAccessibilityEvent(AccessibilityEvent) on each child. Override this method if custom population of the event text content is required.
Within that method, you can add any text you want to the event in the following manner:
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
event.getText().add("Hey look!");
return true;
}
精彩评论