How to hide keyboard for samsung galaxy note programmatically in android

拥有回忆 提交于 2019-12-08 03:43:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!