EditText with textPassword inputType, but without Softkeyboard

早过忘川 提交于 2019-12-31 07:08:08

问题


i wanted to create an EditText with an android:inputType="textPassword. However i also do not want to use the SoftKeyboard for input.

So i tried setting InputMethod to null, but this would also disable the textPassword features of replacing password rendering to "*[lastchar]".

Is there any other way to disable the softKeyboard from showing up?


回答1:


Uhm just figured it out myself:

Simply use:

pinInput.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
            InputMethodManager mgr = (InputMethodManager) Pin.this.getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(v.getWindowToken(), 0);
      }
    });

This works well for me. I feared it might show the SoftKeyboard and then hide it again instantly, or flicker the screen, but does nothing like it.



来源:https://stackoverflow.com/questions/5573614/edittext-with-textpassword-inputtype-but-without-softkeyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!