问题
I am using data and time picker for two edit text, I want to hide keyboard for two edit text.I am doing like this
mDatePickerEdt = (EditText)findViewById(R.id.createwedding_datepicker_edt);
mTimePickerEdt = (EditText)findViewById(R.id.createwedding_timepicker_edt);
mDatePickerEdt.setInputType(InputType.TYPE_NULL);
mTimePickerEdt.setInputType(InputType.TYPE_NULL);
it is working for smart phones.I getting problem in samsung galaxy note.If any one have idea.Please help, Thanks in advance.
回答1:
you can use following code to hide keyboard.
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
回答2:
try this
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
or try input InputMethodManager.HIDE_NOT_ALWAYS instead of 0
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
you can use below code to suppress the keyboard until the user touched the edittext view.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
来源:https://stackoverflow.com/questions/10696848/how-to-hide-keyboard-for-samsung-galaxy-note-programmatically-in-android