Example usage for android.widget ScrollView setAccessibilityDelegate

List of usage examples for android.widget ScrollView setAccessibilityDelegate

Introduction

In this page you can find the example usage for android.widget ScrollView setAccessibilityDelegate.

Prototype

public void setAccessibilityDelegate(@Nullable AccessibilityDelegate delegate) 

Source Link

Document

Sets a delegate for implementing accessibility support via composition (as opposed to inheritance).

Usage

From source file:com.android.switchaccess.SwitchAccessEndToEndTest.java

@MediumTest
public void testScrolling_scroll() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;//from w  w  w  .  j  av a2  s  .  co  m
    }

    final ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scroll_id);
    final CountDownLatch scrollsMissed = new CountDownLatch(1);
    scrollView.setAccessibilityDelegate(new AccessibilityDelegate() {
        @Override
        public boolean performAccessibilityAction(@NonNull View host, int action, Bundle args) {
            if (action == AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) {
                scrollsMissed.countDown();
            }
            return super.performAccessibilityAction(host, action, args);
        }
    });
    sendKeyEventSync(mMoveFocusEvent);
    sendKeyEventSync(mScrollForwardEvent);
    assertEquals(0, scrollsMissed.getCount());
}