0

I've a custom view button and I call setContentDescription multiple times based on the state of the custom view. I'm seeing a odd behavior from talkback, it is reading "Selected <string based on the state>, Button, <string based on old state I set before>". I printed getContentDescription and it never has once this appended format and is always only correctly displaying what is set before. If I comment out the lines of the state I don't want to be seen, I don't see the appended string. So, I'm sure the contentDescription is coming from that previous set call. Anyone knows what the heck is going on?

The code is simply this

void updateContentDescription() {
if (stateEnabled)
setContentDescription(getResources().getString(R.string.content) + " some string")
else
setContentDescription("some other string")
}

This above method is called multiple times, when the state is enabled, I see the output printed as "Selected content some string, Button, some other string"

4
  • Could you please add some example code so we can help you with the best possible context? Commented Mar 11, 2024 at 8:30
  • Oops i added in <> it cleared that content. Sorry. Commented Mar 11, 2024 at 16:16
  • Should I be using stateDescription instead? Looks like that might work better for frequent changes Commented Mar 12, 2024 at 18:42
  • I would say so, yes. The code seems to indicate that if the state is enabled, then change some description. However you may need to be creative around lower API levels. If I could reproduce the problem I could be more helpful Commented Mar 12, 2024 at 18:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.