Mark F Mark F - 1 year ago 138
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) {

Answer Source

Try this in onCreateView or onActivityCreated.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download