我的自定义键盘上有一个android:code =“ 10”的返回键。键盘根据EditorInfo更新keyIcon。
我遇到的问题是,当按钮为'Go'时,意味着EditorInfo.IME_ACTION_GO处于打开状态,按Go不会提交。
返回按钮有效,但是当我在搜索框中键入URL并按Go时,没有任何反应。它只是做一个空格/返回。
我该如何解决?
我可以检查他们是否按了Return键,并且EditorInfo.IME_ACTION_GO为true,然后“提交”,但是我不怎么做。我很确定'Go'功能是由URL文本框实现的,不是我应该做的事情。
您输入的文本编辑器是当前的输入编辑器。
您可以使用currentInputConnection.performEditorAction(EditorInfo.IME_ACTION_GO)或所需的任何其他操作在该输入连接上执行操作。
要使其自动执行所需的输入操作,请使用以下命令:
val imeOptions = currentInputEditorInfo.imeOptions
val action = imeOptions and EditorInfo.IME_MASK_ACTION
currentInputConnection.performEditorAction(action)
[其他有用的链接,例如用于更改键盘上的图标的方式:
Cannot change Enter Key label for Custom keyboard in Android
How to perform a search action by android custom keyboard action button?