I have some TextView
s that I would like to announce as a header or a link in Talkback mode. Currently, it just announces the text inside the TextView
, but I would like it to say "Heading" afterwards, or "link" depending on the TextView
. For example, I would like Talkback mode to announce "Log in - heading" rather than just "Log in".
What I have tried so far is adding this in my Activity
's onCreate()
:
ViewCompat.setAccessibilityDelegate(v, new AccessibilityDelegateCompat() {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
info.setHeading(true);
}
});
In Talkback mode, there is no change - it still just announces "log in".
What I notice is that this method, onInitializeAccessibilityNodeInfo
, is being called multiple times. When I step through in debugger, every time this method is triggered it shows that isHeading()
is false, then set to true.
Am I using this method incorrectly? Why is it called many times? Why is info.setHeading(true)
basically ignored?
How would I accomplish something similar, but with Talkback mode announcing "Label - Link" instead of header?
Try this:
ViewCompat.setAccessibilityDelegate(v, new AccessibilityDelegateCompat() {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
info.setRoleDesccription("heading");
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With