[英]How to make links among other text focusable for accessibility
I have a CheckedTextBox whose text is made up of two SpannableStrings, one of which is a URLSpan.我有一个 CheckedTextBox,它的文本由两个 SpannableStrings 组成,其中一个是 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?我的问题是,如何让用户可以通过每个跨度移动可访问性焦点,最终专注于 URLspan 本身? setMovementMethod
and setLinksClickable
doesn't seem to work for me. setMovementMethod
和setLinksClickable
似乎对我不起作用。
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.我查看了 Android 辅助功能帮助文档,似乎只要用户听到提示音并且可以在本地上下文菜单中看到链接就足够了。 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 https://support.google.com/accessibility/android/answer/6378148?hl=en
Any help would be appreciated.任何帮助将不胜感激。
Maybe this can be the easiest solution..it worked for me.也许这可能是最简单的解决方案..它对我有用。
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClassroomLog.log(TAG, "Textview Click listener ");
if (textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1){
// Perform your action here
}
}
});
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 Android 自己的文档指导用户打开本地上下文菜单以访问 TextViews 中的链接: https : //support.google.com/accessibility/android/answer/6378148?hl= en
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.