Hide virtual keyboard always

2019-07-08 08:18发布

问题:

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