在软键盘的Andr​​oid禁用回车键 [英] Android disable Enter key in soft keyboard

查看:139
本文介绍了在软键盘的Andr​​oid禁用回车键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何禁用和启用<大骨节病>输入软键盘按键?

Can anyone tell me how to disable and enable the Enter key in the soft keyboard?

推荐答案

连接<一href="http://developer.android.com/reference/android/widget/TextView.OnEditorActionListener.html">OnEditorActionListener你的文本字段,并返回其 onEditorAction 方法,当 actionId 真正等于<一个href="http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_DONE">IME_ACTION_DONE.这将prevent软键盘的隐藏:

Attach OnEditorActionListener to your text field and return true from its onEditorAction method, when actionId is equal to IME_ACTION_DONE. This will prevent soft keyboard from hiding:

EditText txtEdit = (EditText) findViewById(R.id.txtEdit);
txtEdit.setOnEditorActionListener(new OnEditorActionListener() {

  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      // your additional processing... 
      return true;
    } else {
      return false;
    }
  }
});

请参照<一href="http://stackoverflow.com/questions/7202369/keep-soft-keyboard-open-when-enter-key-is-$p$pssed">this链接。

这篇关于在软键盘的Andr​​oid禁用回车键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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