I have a CheckedTextBox whose text is made up of two SpannableStrings, one of which is a URLSpan.
My question is, how do I make so that a user can move the accessibility focus through each span, eventually focusing on the URLspan itself? setMovementMethod
and setLinksClickable
doesn't seem to work for me.
SpannableStringBuilder builder = new SpannableStringBuilder();
SpannableString label = new SpannableString(getString(R.string.label));
label.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.text_color_primary)), 0, label.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.append(label);
SpannableString link = new SpannableString(getString(R.string.link);
link.setSpan(new URLSpan(mUrl), 0, link.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.append(link);
builder.append(".");
mCheckedTextBox.setText(builder);
//The following two methods do not work for what I'm trying to accomplish:
mCheckedTextBox.setMovementMethod(LinkMovementMethod.getInstance());
mCheckedTextBox.setLinksClickable(true);
I've checked on the Android Accessibility Help documentation and it seems that as long as the user hears a chime and can see the link in the local context menu, it is sufficient. However, I wanted to see if I can go that extra mile to enable the user to scroll and focus to the link portion of the text. https://support.google.com/accessibility/android/answer/6378148?hl=en
Any help would be appreciated.
This isn't supported by the platform. Android's own documentation directs users to open the Local Context Menu to access links in TextViews: https://support.google.com/accessibility/android/answer/6378148?hl=en