当前位置: 首页>>代码示例>>Java>>正文


Java ViewParent.requestSendAccessibilityEvent方法代码示例

本文整理汇总了Java中android.view.ViewParent.requestSendAccessibilityEvent方法的典型用法代码示例。如果您正苦于以下问题:Java ViewParent.requestSendAccessibilityEvent方法的具体用法?Java ViewParent.requestSendAccessibilityEvent怎么用?Java ViewParent.requestSendAccessibilityEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewParent的用法示例。


在下文中一共展示了ViewParent.requestSendAccessibilityEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: announceForAccessibility

import android.view.ViewParent; //导入方法依赖的package包/类
/**
 * Sends the specified text to the {@link AccessibilityManager} to be
 * spoken.
 *
 * @param view The source view.
 * @param text The text to speak.
 */
public void announceForAccessibility(final View view, final CharSequence text) {
    if (!mAccessibilityManager.isEnabled()) {
        Log.e(TAG, "Attempted to speak when accessibility was disabled!");
        return;
    }

    // The following is a hack to avoid using the heavy-weight TextToSpeech
    // class. Instead, we're just forcing a fake AccessibilityEvent into
    // the screen reader to make it speak.
    final AccessibilityEvent event = AccessibilityEvent.obtain();

    event.setPackageName(PACKAGE);
    event.setClassName(CLASS);
    event.setEventTime(SystemClock.uptimeMillis());
    event.setEnabled(true);
    event.getText().add(text);

    // Platforms starting at SDK version 16 (Build.VERSION_CODES.JELLY_BEAN) should use
    // announce events.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        event.setEventType(AccessibilityEventCompat.TYPE_ANNOUNCEMENT);
    } else {
        event.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    }

    final ViewParent viewParent = view.getParent();
    if ((viewParent == null) || !(viewParent instanceof ViewGroup)) {
        Log.e(TAG, "Failed to obtain ViewParent in announceForAccessibility");
        return;
    }

    viewParent.requestSendAccessibilityEvent(view, event);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:41,代码来源:AccessibilityUtils.java

示例2: sendWindowStateChanged

import android.view.ViewParent; //导入方法依赖的package包/类
/**
 * Sends a window state change event with the specified text.
 *
 * @param text The text to send with the event.
 */
protected void sendWindowStateChanged(final String text) {
    final AccessibilityEvent stateChange = AccessibilityEvent.obtain(
            AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    mKeyboardView.onInitializeAccessibilityEvent(stateChange);
    stateChange.getText().add(text);
    stateChange.setContentDescription(null);

    final ViewParent parent = mKeyboardView.getParent();
    if (parent != null) {
        parent.requestSendAccessibilityEvent(mKeyboardView, stateChange);
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:18,代码来源:KeyboardAccessibilityDelegate.java

示例3: requestSendAccessibilityEvent

import android.view.ViewParent; //导入方法依赖的package包/类
public static boolean requestSendAccessibilityEvent(ViewParent parent, View child, AccessibilityEvent event) {
    return parent.requestSendAccessibilityEvent(child, event);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ViewParentCompatICS.java


注:本文中的android.view.ViewParent.requestSendAccessibilityEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。