Android accessibility for title definition

I have the latest version of Talkback and its ad "My Top Level Text Heading". Android's native behavior adds a “Title” to my top-level items. I could not find a way to turn on / off the header. Is there an API to control its behavior. In the previous version of the Talkback version, she did not declare "Heading" on her own.

+4
source share
2 answers

If you only support API level 23 and above, you can simply do the following.

textView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
  @Override
  public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    //blanked to prevent talkback from announcing class/type
    info.setClassName("");
  }
});
+1
source

I solved this by skipping the header as false in

AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain method.

        // set the heading attribute to false so that heading is not announced in label  

info.setCollectionItemInfo(
    AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(glp.getSpanIndex(),
 glp.getSpanSize(), spanGroupIndex, 1, false, false));

public static CollectionItemInfoCompat obtain(int rowIndex, 
int rowSpan, int columnIndex, int columnSpan,
boolean heading, boolean selected)
0
source

Source: https://habr.com/ru/post/1658644/


All Articles