I have a TextView and an EditText. The TextView uses android:labelFor="@+id/EditTextId"
;
The EditText also has a hint that represents and example of input, that I only want to be visible for the users that do not use TalkBack, and not be read by the TalkBack.
android:contentDescription="Mandatory field"
android:hint="Example of input"
The TalkBack would usually read (how I want it to work):
"Mandatory field, Edit Box for Text View"
but instead, reads:
"Example of input, Edit Box for Text View"
This was possible by doing:
View.AccessibilityDelegate accessibilityDelegate = new View.AccessibilityDelegate() {
@Override
public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(v, info);
info.setText("Mandatory field");
}
};
myEditTex.setAccessibilityDelegate(accessibilityDelegate);
This way, the accessibility TalkBack will read: "Mandatory field " + "Edit box for " + the TextView that has android:labelFor