Hide virtual keyboard always

独自空忆成欢 提交于 2019-12-10 23:15:10

问题


Actually i have a edit text.when i click edit text virtual keyboard popups.But i just wanna hide virtual keyboard always even after click on edit text.And edit text should be printable with system keyboard.How could i do this? My code..

EditText edtNote = (EditText)findViewById(R.id.note);
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.restartInput(edtNote);

Configuration config = this.getResources().getConfiguration();

if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

回答1:


Try edtNote.setInputType(InputType.Type_Null); it has advantages and disadvantage. Android wont treat the element as an input element. You cant enter anything after this



来源:https://stackoverflow.com/questions/4836801/hide-virtual-keyboard-always

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