Code example for AccessibilityEvent

Methods: getEventType, setCurrentItemIndex, setEnabled, setEventType, setItemCount

0
        boolean populated = false;
        // This is an exceptional case which occurs when a window gets the 
        // focus and sends a focus event via its focused child to announce 
        // current focus/selection. AdapterView fires selection but not focus 
        // events so we change the event type here. 
        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
            event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED);
        } 
 
        // we send selection events only from AdapterView to avoid 
        // generation of such event for each child 
        View selectedView = getSelectedView();
        if (selectedView != null) {
            populated = selectedView.dispatchPopulateAccessibilityEvent(event);
        } 
 
        if (!populated) {
            if (selectedView != null) {
                event.setEnabled(selectedView.isEnabled());
            } 
            event.setItemCount(getCount());
            event.setCurrentItemIndex(getSelectedItemPosition());
        } 
 
        return populated;
    }