Code example for AccessibilityEvent

Methods: setClassName, setCurrentItemIndex, setEnabled, setFromIndex, setItemCount, setScrollable, setToIndex

0
    } 
 
    @Override 
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
        event.setClassName(AdapterView.class.getName());
        event.setScrollable(isScrollableForAccessibility());
        View selectedView = getSelectedView();
        if (selectedView != null) {
            event.setEnabled(selectedView.isEnabled());
        } 
        event.setCurrentItemIndex(getSelectedItemPosition());
        event.setFromIndex(getFirstVisiblePosition());
        event.setToIndex(getLastVisiblePosition());
        event.setItemCount(getCount());
    } 
 
    private boolean isScrollableForAccessibility() { 
        T adapter = getAdapter();
        if (adapter != null) {
            final int itemCount = adapter.getCount();