自定义Android键盘'Go'不提交URL或其他内容?

问题描述 投票:0回答:1

我的自定义键盘上有一个android:code =“ 10”的返回键。键盘根据EditorInfo更新keyIcon。

我遇到的问题是,当按钮为'Go'时,意味着EditorInfo.IME_ACTION_GO处于打开状态,按Go不会提交。

返回按钮有效,但是当我在搜索框中键入URL并按Go时,没有任何反应。它只是做一个空格/返回。

我该如何解决?

我可以检查他们是否按了Return键,并且EditorInfo.IME_ACTION_GO为true,然后“提交”,但是我不怎么做。我很确定'Go'功能是由URL文本框实现的,不是我应该做的事情。

https://i.imgur.com/pYmLmwu.png

java android android-studio android-softkeyboard
1个回答
0
投票

您输入的文本编辑器是当前的输入编辑器。

您可以使用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?

© www.soinside.com 2019 - 2024. All rights reserved.