Android: Disable soft keyboard at all EditTexts
I am working on a dialog at Android with a few EditText
s.
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?
Solution 1:
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.
Solution 2:
create your own class that extends EditText
and override the onCheckIsTextEditor()
:
public class NoImeEditText extends EditText {
public NoImeEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onCheckIsTextEditor() {
return false;
}
}
Solution 3:
Try this out..
edittext.setInputType(InputType.TYPE_NULL);
if (android.os.Build.VERSION.SDK_INT >= 11)
{
edittext.setRawInputType(InputType.TYPE_CLASS_TEXT);
edittext.setTextIsSelectable(true);
}