开始时关闭Android键盘

时间:2012-11-17 19:21:18

标签: java android

我有一个来自xml的变量:

  

editTextInput =(EditText)findViewById(R.id.editTextInput);

当应用程序加载时,键盘会显示,但是我想隐藏它,如果用户想要将其恢复,则必须单击EditText字段才能显示它。

2 个答案:

答案 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);