announceForAccessibility doesn't work without Handler().postDelayed

671 Views Asked by At

I have an EditText for user to input email and a TextView to show error but default is hidden and finally a submit button on the screen. We can't display error message using TextInputLayout because of the requirement coming from design.

What happen is when user clicks on submit button, we call textview.announceForAccessibility("hello"); if email is invalid. This works if the green rect stays on submit button, but it doesn't always like that. If green rect is on EditText, talkback only describe the EditText and totally ignore the error message. However, if I add a second delay to it, it works. new Handler().postDelayed(() -> textview.announceForAccessibility("hello"), 1000);

I don't really understand why and how to solve the issue correctly.

0

There are 0 best solutions below