我试图遍历ListView,为每个项目实现click事件,但不起作用。 请问为什么点击没有效果?
public void addFriendSearch(AccessibilityNodeInfo info) {
try {
L.i(TAG, "-addFriendSearch-parent widget----------------------------" + info.getClassName());
L.i(TAG, "--Text:" + info.getText());
L.i(TAG, "--windowId:" + info.getWindowId());
boolean contentInvalid = info.isVisibleToUser();
L.i(TAG, "--contentInvalid:" + contentInvalid);
for (int i = 0; i < info.getChildCount(); i++) {
AccessibilityNodeInfo child = info.getChild(i);
boolean equals = child.getClassName().equals("android.widget.ListView");
if(equals){
for (int j = 0; j < child.getChildCount(); j++) {
L.i("listview child:"+j);
AccessibilityNodeInfo child1 = child.getChild(j);
if (child1 != null) {
if (child1.isClickable()) {
L.i("listview child click");
info.performAction(AccessibilityNodeInfo.ACTION_CLICK); // click
}
}
}
}else{
if(child!=null){
addFriendSearch(info.getChild(i));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
或如何参加活动?