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

问题描述

谁能告诉我如何禁用和启用输入软键盘按键?

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

推荐答案

连接OnEditorActionListener你的文本字段,并返回其 onEditorAction 方法,当 actionId 真正等于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禁用回车键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 22:50