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?
Hiding the Soft Keyboard Programmatically You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.
Ok everyone knows that to hide a keyboard you need to implement: InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow(getCurrentFocus(). getWindowToken(), 0);
What to Know. Go to Settings > System > Languages & input. Tap Virtual keyboard and choose your keyboard. You can switch between keyboards by selecting the keyboard icon at the bottom of most keyboard apps.
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.
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; } }
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With