Android AccessibilityNodeInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AccessibilityNodeInfo class.

This code example shows how to use the following methods:setClassName, setEnabled, setScrollable
    } 
 
    @SuppressLint("NewApi") 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(AdapterView.class.getName());
        info.setScrollable(isScrollableForAccessibility());
        View selectedView = getSelectedView();
        if (selectedView != null) {
            info.setEnabled(selectedView.isEnabled());
        } 
    } 
 
    @Override 
    protected void onLayout(boolean changed, int left, int top, int right,
                            int bottom) {
        mLayoutHeight = getHeight();
    } 
 
8
CodeRank
This code example shows how to use the following methods:setCheckable, setChecked, setText
        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
            super.onInitializeAccessibilityNodeInfo(info);
            // We called the super implementation to let super classes set 
            // appropriate info properties. Then we add our properties 
            // (checkable and checked) which are not supported by a super class. 
            info.setCheckable(true);
            info.setChecked(isChecked());
            // Very often you will need to add only the text on the custom view. 
            CharSequence text = getText();
            if (!TextUtils.isEmpty(text)) {
                info.setText(text);
            } 
        } 
 
        @Override 
        public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
            super.onPopulateAccessibilityEvent(event);
            // We called the super implementation to populate its text to the 
            // event. Then we add our text not present in a super class. 
            // Very often you will need to add only the text on the custom view. 
7
CodeRank
This code example shows how to use the following methods:addAction, setClickable, setMovementGranularities
        super(view);
    } 
 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
        info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
        info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
        info.addAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT);
        info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT);
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
        info.setClickable(true);
    } 
 
    @Override 
    public boolean supportsAccessibilityAction(int action) {
        if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY ||
7
CodeRank
This code example shows how to use the following methods:getText, setClassName, setText
 
    @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(Switch.class.getName());
        CharSequence switchText = isChecked() ? mTextOn : mTextOff;
        if (!TextUtils.isEmpty(switchText)) {
            CharSequence oldText = info.getText();
            if (TextUtils.isEmpty(oldText)) {
                info.setText(switchText);
            } else { 
                StringBuilder newText = new StringBuilder();
                newText.append(oldText).append(' ').append(switchText);
                info.setText(newText);
            } 
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:addAction, setClickable, setMovementGranularities
        super(view);
    } 
 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH |
                AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE);
        info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
        info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
        info.addAction(AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT);
        info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT);
        info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
        info.setClickable(true);
    } 
 
    @Override 
    public boolean supportsAccessibilityAction(int action) {
        if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY ||
7
CodeRank
This code example shows how to use the following methods:setCheckable, setChecked, setText
                        AccessibilityNodeInfo info) {
                    super.onInitializeAccessibilityNodeInfo(host, info);
                    // We called the super implementation to let super classes set 
                    // appropriate info properties. Then we add our properties 
                    // (checkable and checked) which are not supported by a super class. 
                    info.setCheckable(true);
                    info.setChecked(isChecked());
                    // Very often you will need to add only the text on the custom view. 
                    CharSequence text = getText();
                    if (!TextUtils.isEmpty(text)) {
                        info.setText(text);
                    } 
                } 
 
                @Override 
                public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
                    super.onPopulateAccessibilityEvent(host, event);
                    // We called the super implementation to populate its text to the 
                    // event. Then we add our text not present in a super class. 
                    // Very often you will need to add only the text on the custom view. 
7
CodeRank
This code example shows how to use the following methods:setCheckable, setChecked, setText
                        AccessibilityNodeInfo info) {
                    super.onInitializeAccessibilityNodeInfo(host, info);
                    // We called the super implementation to let super classes set 
                    // appropriate info properties. Then we add our properties 
                    // (checkable and checked) which are not supported by a super class. 
                    info.setCheckable(true);
                    info.setChecked(isChecked());
                    // Very often you will need to add only the text on the custom view. 
                    CharSequence text = getText();
                    if (!TextUtils.isEmpty(text)) {
                        info.setText(text);
                    } 
                } 
 
                @Override 
                public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
                    super.onPopulateAccessibilityEvent(host, event);
                    // We called the super implementation to populate its text to the 
                    // event. Then we add our text not present in a super class. 
                    // Very often you will need to add only the text on the custom view. 
7
CodeRank
This code example shows how to use the following methods:setEnabled, setScrollable
    } 
 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setScrollable(isScrollableForAccessibility());
        View selectedView = getSelectedView();
        if (selectedView != null) {
            info.setEnabled(selectedView.isEnabled());
        } 
    } 
 
    @Override 
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
        event.setScrollable(isScrollableForAccessibility());
        View selectedView = getSelectedView();
        if (selectedView != null) {
            event.setEnabled(selectedView.isEnabled());
        } 
6
CodeRank
This code example shows how to use the following methods:setClassName, setEnabled, setScrollable
    } 
 
    @SuppressLint("NewApi") 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(AdapterView.class.getName());
        info.setScrollable(isScrollableForAccessibility());
        View selectedView = getSelectedView();
        if (selectedView != null) {
            info.setEnabled(selectedView.isEnabled());
        } 
    } 
 
    @Override 
    protected void onLayout(boolean changed, int left, int top, int right,
            int bottom) {
        mLayoutHeight = getHeight();
    } 
 
6
CodeRank
This code example shows how to use the following methods:setClassName
    } 
 
    @Override 
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(Button.class.getName());
    } 
} 
6
CodeRank

Related Android AccessibilityNodeInfo Questions & Answers:

See Code Examples for Android AccessibilityNodeInfo Methods: