的performAction为什么(AccessibilityNodeInfo.ACTION_CLEAR_FOCUS)总是EDITTEXT返回false? [英] Why performAction(AccessibilityNodeInfo.ACTION_CLEAR_FOCUS) always return false on editText?

查看:5155
本文介绍了的performAction为什么(AccessibilityNodeInfo.ACTION_CLEAR_FOCUS)总是EDITTEXT返回false?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要清除输入焦点从一个EditText在我的辅助服务上的特定行动。

I want to clear the input focus from an editText in my accessibility service on a specific action.

我得到输入焦点的节点,并尝试将其清除,但总的performAction返回false:

I get the node with the input focus and try to clear it but performAction always return false:

AccessibilityNodeInfo root = getRootInActiveWindow();
AccessibilityNodeInfo focus = root.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);

if(focus != null){

    focus.getText(); //return the text in my input
    focus.isFocusable(); //return true
    focus.isFocused(); // return true
    focus.getActions(); //Return the bitmask that contain the Action_clear_focus

    boolean sucess = focus.performAction(AccessibilityNodeInfo.ACTION_CLEAR_FOCUS);
    Log.v(TAG, "sucess = " + sucess); //Always return FALSE

}

为什么不能执行该操作?

Why the action cannot be performed?

推荐答案

如果你明确的重点从视图,该视图框架将试图将焦点回到屏幕上的第一个聚焦元素上。所以,如果在屏幕上一个聚焦元素,像一个EditText,它总是具有焦点 - 即使你调用clearFocus()

If you clear focus from a view, the view framework will attempt to place focus back on the first focusable element on the screen. So, if there is a single focusable element on screen, like an EditText, it will always have focus -- even if you call clearFocus().

这篇关于的performAction为什么(AccessibilityNodeInfo.ACTION_CLEAR_FOCUS)总是EDITTEXT返回false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆