Android的 - 处理" Enter]键。在一个EditText [英] Android - Handle "Enter" in an EditText

查看:166
本文介绍了Android的 - 处理" Enter]键。在一个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和<一href="http://developer.android.com/reference/android/widget/TextView.html#attr_android%3aimeOptions"><$c$c>android:imeOptions属性,加<一href="http://developer.android.com/reference/android/widget/TextView.html#setOnEditorActionListener%28android.widget.TextView.OnEditorActionListener%29"><$c$c>setOnEditorActionListener()法,都在的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屋!

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