问题
I'm having a minor headache with the TalkBack screen reader service when reading phone numbers in a WebView, and I can't seem to find a solution. This is a snippet of some html code that I am reading into the WebView:
<li>Call <a href="tel:18007848669">1-800-QUIT-NOW(1-800-784-8669)</a> for phone support</li>
The screen reader reads this as "Call one to eight hundred quit now one to eight hundred link". Is there a way to force it/signal to read it differently? I need it to be read in a more natural format, i.e. "One Eight Hundred".
回答1:
For this element, android:contentDescription="One eight hundred quit now"
回答2:
Use the following Accessibility Deligate for your editText or textView
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
switch (host.getId()) {
case R.id.tv_bookingID:
if (((TextView) host).getText().length() > 1) {
sb.delete(0, sb.length());
for (char c : ((TextView) host).getText().toString().toCharArray()) {
sb.append(c).append(" ");
}
//change text for talkback
info.setText(null);
info.setContentDescription(sb.toString().trim());
}
break;
}//switch
}//if
}
来源:https://stackoverflow.com/questions/15371057/android-talkback-reading-phone-numbers-in-webview-incorrectly