android - 如何在默认键盘上放置一个按钮?我想要一个按钮,当按下它时,它有机会进行另一项 Activity

标签 android android-edittext android-softkeyboard

我的 Activity 中有一个 EditText。我希望当用户完成文本时,他可以移动到下一个 Activity 而无需按后退按钮隐藏键盘。我想知道是否有办法在软键盘上放置一个按钮以转到下一个 Activity 。

(抱歉英语不好,不是我的母语)

最佳答案

您不能向现有键盘添加按钮。但是,您可以为自定义 IME 操作建议标签和 ID。参见 TextView.setImeActionLabel :

Change the custom IME action associated with the text view, which will be reported to an IME with actionLabel and actionId when it has focus.

然后您必须调用 TextView.setOnEditorActionListener提供自定义监听器来监听该 IME 事件,然后您可以在其中进行下一个 Activity 。

关于android - 如何在默认键盘上放置一个按钮?我想要一个按钮,当按下它时,它有机会进行另一项 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18111059/

相关文章:

android - EditText 获得焦点后不会失去焦点

android - StateListDrawable 在 KeyboardView 的 OnDraw() 方法中不起作用

android - 如何自定义android Material 调色板

java - 使用 for 循环将 EditText 添加到 android 中的布局

android - Horizo​​ntalView 和 ScrollView 可以容纳 Fragment 吗?

Android 编辑文本 : How to apply Foreground color span as you type?

android - 软键盘在Android中的 Activity 中打开和关闭监听器

android - 使用软键盘查看移动,阻止其他 UI 对象

android - 找不到符号类指南

android - 检测匿名/隐身浏览