Code example for AccessibilityNodeInfo

Methods: addAction, setScrollable

0
 
    /* Accessibility */ 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setScrollable(getPageCount() > 1);
        if (getCurrentPage() < getPageCount() - 1) { 
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        } 
        if (getCurrentPage() > 0) { 
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        } 
    } 
 
    @Override 
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
        event.setScrollable(true);
        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
            event.setFromIndex(mCurrentPage);
            event.setToIndex(mCurrentPage);