@SuppressLint("NewApi")
    @Override
    public boolean performAccessibilityAction(int action, Bundle arguments) {
        if (action != AccessibilityNodeInfo.ACTION_SCROLL_FORWARD &&
                action != AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
            return super.performAccessibilityAction(action, arguments);
        }

        // Figure out what month is showing.
        int firstVisiblePosition = getFirstVisiblePosition();
        int month = firstVisiblePosition % 12;
        int year = firstVisiblePosition / 12 + mController.getMinYear();
        CalendarDay day = new CalendarDay(year, month, 1);

        // Scroll either forward or backward one month.
        if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) {
            day.month++;
            if (day.month == 12) {
                day.month = 0;
                day.year++;
            }
        } else if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
            View firstVisibleView = getChildAt(0);
            // If the view is fully visible, jump one month back. Otherwise, we'll just jump
            // to the first day of first visible month.
            if (firstVisibleView != null && firstVisibleView.getTop() >= -1) {
                // There's an off-by-one somewhere, so the top of the first visible item will
                // actually be -1 when it's at the exact top.
                day.month--;
                if (day.month == -1) {
                    day.month = 11;
                    day.year--;
                }
            }
        }

        // Go to that month.
        DateTimePickerUtils.tryAccessibilityAnnounce(this, getMonthAndYearString(day));
        goTo(day, true, false, true);
        mPerformingScroll = true;
        return true;
    }
@ SuppressLint ( "NewApi" ) @ Override public boolean performAccessibilityAction ( int action , Bundle arguments ) { if ( action != AccessibilityNodeInfo . ACTION_SCROLL_FORWARD && action != AccessibilityNodeInfo . ACTION_SCROLL_BACKWARD ) { return super . performAccessibilityAction ( action , arguments ) ; } int firstVisiblePosition = getFirstVisiblePosition ( ) ; int month = firstVisiblePosition % 12 ; int year = firstVisiblePosition / 12 + mController . getMinYear ( ) ; CalendarDay day = new CalendarDay ( year , month , 1 ) ; if ( action == AccessibilityNodeInfo . ACTION_SCROLL_FORWARD ) { day . month ++ ; if ( day . month == 12 ) { day . month = 0 ; day . year ++ ; } } else if ( action == AccessibilityNodeInfo . ACTION_SCROLL_BACKWARD ) { View firstVisibleView = getChildAt ( 0 ) ; if ( firstVisibleView != null && firstVisibleView . getTop ( ) >= - 1 ) { day . month -- ; if ( day . month == - 1 ) { day . month = 11 ; day . year -- ; } } } DateTimePickerUtils . tryAccessibilityAnnounce ( this , getMonthAndYearString ( day ) ) ; goTo ( day , true , false , true ) ; mPerformingScroll = true ; return true ; }
When scroll forward/backward events are received, announce the newly scrolled-to month.