Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SoftInputMode不能设置为隐藏_Android_Android Softkeyboard - Fatal编程技术网

Android SoftInputMode不能设置为隐藏

Android SoftInputMode不能设置为隐藏,android,android-softkeyboard,Android,Android Softkeyboard,我创建了一个带有对话框主题的活动,它有一个EditText。 我不想在每个活动上都显示软输入,因此我在该活动上使用了以下代码: EditText editTextData=GetView(R.id.txtData); editTextPin.requestFocus(); InputMethodManager mgr = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); mgr.showSoftIn

我创建了一个带有对话框主题的活动,它有一个EditText。 我不想在每个活动上都显示软输入,因此我在该活动上使用了以下代码:

 EditText editTextData=GetView(R.id.txtData);
    editTextPin.requestFocus();
    InputMethodManager mgr = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    mgr.showSoftInput(editTextData, InputMethodManager.SHOW_IMPLICIT);
这使输入键盘可见。 输入后,我尝试使用以下代码将其隐藏:

 InputMethodManager mgr = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        mgr.hideSoftInputFromInputMethod(editTextData.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
它仍然可见。我还应该打什么电话?

试试

管理器.hideSoftInputFromInputMethod(editTextData.getWindowToken(), 1);

试一试

InputMethodManager管理器=(InputMethodManager)getSystemService( 上下文。输入方法(服务);mgr.hideSoftInputFromWindow(editTextData.getWindowToken(),0)


您可以使用以下功能隐藏键盘

private void hideSoftKeyboard(Activity act) {
    InputMethodManager inputMethodManager = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(act.getCurrentFocus().getWindowToken(), 0);
}

希望它能帮助您..

不幸的是,它仍然可见。不幸的是,它仍然可见。