find Accessibility Node Information By Texts - Android User Interface

Android examples for User Interface:AccessibilityEvent

Description

find Accessibility Node Information By Texts

Demo Code


//package com.java2s;

import android.view.accessibility.AccessibilityNodeInfo;

import java.util.List;

public class Main {

    public static AccessibilityNodeInfo findNodeInfosByTexts(
            AccessibilityNodeInfo nodeInfo, String... texts) {
        for (String key : texts) {
            AccessibilityNodeInfo info = findNodeInfosByText(nodeInfo, key);
            if (info != null) {
                return info;
            }// w  w w.ja va 2  s.co  m
        }
        return null;
    }

    public static AccessibilityNodeInfo findNodeInfosByText(
            AccessibilityNodeInfo nodeInfo, String text) {
        List<AccessibilityNodeInfo> list = nodeInfo
                .findAccessibilityNodeInfosByText(text);
        if (list == null || list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }
}

Related Tutorials