Accessibility Dialog / DialogFragment dialog reads text instead of description of content

I have a dialog that has few text views. For each text view, I set a different description and description text. E.g.

<TextView
    android:id="@+id/tv_3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:contentDescription="TV 3"
    android:text="Text Number 3" />

When I show the dialog to the user, Talkback reads the text (i.e. text number 3) of each text field, and not the description of the content (i.e. TV 3).

However, if I hover over any text image, Talkback reads the description of the content.

How to make it read the description of the content when displaying a dialog?

PS: I tried to set the content description in the layout as well as through the code, but no luck

Thanks in advance.

+2
1

, AccessibilityEvents . , -, TalkBack, , TextView AccessibilityDelegate .

, , onPopulateAccessibilityEvent() , .

, TextView:

public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
    // The super method would normally add the text, but we want to
    // add the content description instead. No need to call super.
    event.getText().add(getContentDescription());
}

, , , . , .

+2

All Articles