下面列出了android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#isChecked ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void format(Editable result,
Context context,
AccessibilityNodeInfoCompat node) {
int oldLength = result.length();
CharSequence text = null;
AccessibilityNodeInfoCompat labeledBy = node.getLabeledBy();
if (labeledBy != null) {
text = LabelingUtils.getNodeText(labeledBy, getLabelManager());
labeledBy.recycle();
}
if (text == null) {
text = LabelingUtils.getNodeText(node, getLabelManager());
}
if (text == null) {
text = "";
}
result.append(text);
if (node.isCheckable() || node.isChecked()) {
CharSequence mark;
if (node.isChecked()) {
mark = context.getString(R.string.checkmark_checked);
} else {
mark = context.getString(R.string.checkmark_not_checked);
}
StringUtils.appendWithSpaces(result, mark);
}
if (oldLength == result.length()
&& AccessibilityNodeInfoUtils.isActionableForAccessibility(
node)) {
result.append(getFallbackText(context, node));
}
}
/**
* Gets a description of the properties of a node.
*/
public static CharSequence nodeDebugDescription(AccessibilityNodeInfoCompat node) {
StringBuilder sb = new StringBuilder();
sb.append(node.getWindowId());
if (node.getClassName() != null) {
appendSimpleName(sb, node.getClassName());
} else {
sb.append("??");
}
if (!node.isVisibleToUser()) {
sb.append(":invisible");
}
if (node.getText() != null) {
sb.append(":");
sb.append(node.getText().toString().trim());
}
if (node.getContentDescription() != null) {
sb.append(":");
sb.append(node.getContentDescription().toString().trim());
}
int actions = node.getActions();
if (actions != 0) {
sb.append(":");
if ((actions & AccessibilityNodeInfoCompat.ACTION_FOCUS) != 0) {
sb.append("F");
}
if ((actions & AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS) != 0) {
sb.append("A");
}
if ((actions & AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) {
sb.append("a");
}
if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD) != 0) {
sb.append("-");
}
if ((actions & AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) != 0) {
sb.append("+");
}
}
if (node.isCheckable()) {
sb.append(":");
if (node.isChecked()) {
sb.append("(X)");
} else {
sb.append("( )");
}
}
if (node.isFocusable()) {
sb.append(":focusable");
}
if (node.isFocused()) {
sb.append(":focused");
}
if (node.isSelected()) {
sb.append(":selected");
}
if (node.isClickable()) {
sb.append(":clickable");
}
if (node.isLongClickable()) {
sb.append(":longClickable");
}
if (node.isAccessibilityFocused()) {
sb.append(":accessibilityFocused");
}
if (!node.isEnabled()) {
sb.append(":disabled");
}
return sb.toString();
}