我有一个来自xml的变量:
editTextInput =(EditText)findViewById(R.id.editTextInput);
当应用程序加载时,键盘会显示,但是我想隐藏它,如果用户想要将其恢复,则必须单击EditText字段才能显示它。
答案 0 :(得分:2)
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
答案 1 :(得分:0)
这应该有效:
InputMethodManager inputManager =
(InputMethodManager) context.
getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(
this.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);