Example usage for android.view.accessibility AccessibilityEvent setAction

List of usage examples for android.view.accessibility AccessibilityEvent setAction

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityEvent setAction.

Prototype

public void setAction(int action) 

Source Link

Document

Sets the performed action that triggered this event.

Usage

From source file:cc.flydev.launcher.Page.java

private void sendScrollAccessibilityEvent() {
    AccessibilityManager am = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        AccessibilityEvent ev = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED);
        ev.setItemCount(getChildCount());
        ev.setFromIndex(mCurrentPage);/*from ww  w. j a v  a 2 s. c o m*/

        final int action;
        if (getNextPage() >= mCurrentPage) {
            action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
        } else {
            action = AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
        }

        ev.setAction(action);
        sendAccessibilityEventUnchecked(ev);
    }
}