Android的 - 处理" Enter]键。在一个EditText [英] Android - Handle "Enter" in an EditText
问题描述
我想知道是否有一种方法来处理用户pressing <大骨节病>输入骨节病>打字时的的EditText
,有点像的onsubmit HTML事件。
另外不知道是否有一种方法可以在这样一种方式,完成按钮被其他标记的东西(例如,去),进行点击时(再次,像的onSubmit)某个动作操纵虚拟键盘。
我想知道是否有一种方法来 处理用户pressing <大骨节病>输入骨节病>而 键入一个EditText,像 使用onSubmit HTML事件。
是的。
也想知道是否有办法 操纵虚拟键盘在 这样的方式的完成按钮是 标有别的东西(例如 去),并进行了一定作用 点击时(同样,像的onsubmit)。
还不错。
您会想看看<一href="http://developer.android.com/reference/android/widget/TextView.html#attr_android%3aimeActionId"><$c$c>android:imeActionId$c$c>和<一href="http://developer.android.com/reference/android/widget/TextView.html#attr_android%3aimeOptions"><$c$c>android:imeOptions$c$c>属性,加<一href="http://developer.android.com/reference/android/widget/TextView.html#setOnEditorActionListener%28android.widget.TextView.OnEditorActionListener%29"><$c$c>setOnEditorActionListener()$c$c>法,都在的TextView
。
有关改变的完成按钮上的文本到自定义字符串,可以使用:
mEditText.setImeActionLabel(自定义文本,KeyEvent.KEY code_ENTER);
I am wondering if there is a way to handle the user pressing Enter while typing in an EditText
, something like the onSubmit HTML event.
Also wondering if there is a way to manipulate the virtual keyboard in such a way that the "Done" button is labeled something else (for example "Go") and performs a certain action when clicked (again, like onSubmit).
I am wondering if there is a way to handle the user pressing Enter while typing in an EditText, something like the onSubmit HTML event.
Yes.
Also wondering if there is a way to manipulate the virtual keyboard in such a way that the "Done" button is labeled something else (for example "Go") and performs a certain action when clicked (again, like onSubmit).
Also yes.
You will want to look at the android:imeActionId
and android:imeOptions
attributes, plus the setOnEditorActionListener()
method, all on TextView
.
For changing the text of the "Done" button to a custom string, use:
mEditText.setImeActionLabel("Custom text", KeyEvent.KEYCODE_ENTER);
这篇关于Android的 - 处理&QUOT; Enter]键。在一个EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!