Mark F Mark F - 7 months ago 77
Android Question

Closing Soft Keyboard in Fragment

I found a number of answers to this question but none of them are working for me. I have an Edit text in my Fragment, which gets launched when the application starts. When this Fragment opens, the soft keyboard pops up as well. How do I prevent that from happening? This is what I have in my onCreateView method in my Fragment....

try {
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(
imm.hideSoftInputFromWindow(userName.getWindowToken(), 0);
}catch(Exception e) {


Try this in onCreateView or onActivityCreated.