Android: Disable soft keyboard at all EditTexts

前端 未结 13 2368
失恋的感觉
失恋的感觉 2020-11-27 06:23

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:



        
13条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 07:02

    If you take look on onCheckIsTextEditor() method implementation (in TextView), it looks like this:

    @Override
    public boolean onCheckIsTextEditor() {
        return mInputType != EditorInfo.TYPE_NULL;
    }
    

    This means you don't have to subclass, you can just:

    ((EditText) findViewById(R.id.editText1)).setInputType(InputType.TYPE_NULL); 
    

    I tried setting android:inputType="none" in layout xml but it didn't work for me, so I did it programmatically.

提交回复
热议问题