Code example for AccessibilityEvent

Methods: setChecked

0
        public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
            super.onInitializeAccessibilityEvent(event);
            // We called the super implementation to let super classes 
            // set appropriate event properties. Then we add the new property 
            // (checked) which is not supported by a super class. 
            event.setChecked(isChecked());
        } 
 
        @Override 
        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
            super.onInitializeAccessibilityNodeInfo(info);
            // We called the super implementation to let super classes set 
            // appropriate info properties. Then we add our properties 
            // (checkable and checked) which are not supported by a super class. 
            info.setCheckable(true);
            info.setChecked(isChecked());
            // Very often you will need to add only the text on the custom view. 
            CharSequence text = getText();
            if (!TextUtils.isEmpty(text)) {
                info.setText(text);
            }