且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的:在所有EditTexts关闭软键盘

更新时间:2022-12-19 16:42:57

创建你自己的类,它扩展的EditText和覆盖onCheckIsTextEditor():

 公共类NoImeEditText扩展的EditText {
  公共EditTextEx(上下文的背景下,ATTRS的AttributeSet){
  超(背景下,ATTRS);
  }
  @覆盖
  公共布尔onCheckIsTextEditor(){
  返回false;
  }
  }
 

I am working on a dialog at Android with a few EditTexts. I've put this line at the onCreate() in order to disable the soft keyboard:

Keypad.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

The problem is that it works only when the dialog appear and doing nothing. When I move to the next EditText, the keyboard appears and not going down.

Does anybody have an idea how to solve this issue?

create your own class that extends EditText and override the onCheckIsTextEditor():

public class NoImeEditText extends EditText {
  public EditTextEx(Context context, AttributeSet attrs) { 
  super(context, attrs);     
  }      
  @Override      
  public boolean onCheckIsTextEditor() {   
  return false;     
  }        
  }