抓住“OK”按钮与按“圆形箭头” Android 中的 EditText
我有一个带有 android:inputType="phone"
键盘的 EditText。该键盘上有一个“OK”
。我喜欢按下这个“确定”按钮。但我不知道关键事件。我想使用这样的代码:
setOnKeyListener(new OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (keyCode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.?????????? <- this one please
return true;
default:
break;
}
}
return false;
}
});
我希望代码与按“圆形箭头”不同!
我检查了文档中的所有关键事件,但找不到任何内容。 谢谢
I have an EditText with android:inputType="phone"
keybord. There is an "OK"
on this keyboard. I like to catch pressing this OK btn. However I don't know the key event. I would like to use code like this:
setOnKeyListener(new OnKeyListener()
{
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (keyCode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.?????????? <- this one please
return true;
default:
break;
}
}
return false;
}
});
I hope the code is different from pressing the "round-arrow"!
I checked all the key events in the docs but could not find anything.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“确定”按钮通常与完成输入相关联,并且与其他按钮不同。使用 setOnEditorActionListener 来捕获它:
The 'OK' button is usually associated with finishing the input, and is different from the others. Use
setOnEditorActionListener
to catch it: