I have an Android app that contains a ViewPager with 2 fragments. The first fragment contains the EditText field. When the application starts, this field immediately focuses and the soft keyboard launches (what I want to do). The second fragment contains only a list (no editable text fields). When I make my way from fragment 1 to fragment 2, I would like the keyboard to go away. Nothing I tried seems to work. The keyboard not only remains in sight, it continues to update the EditText field of fragment 1.
I believe that I am using the wrong code to hide the keyboard or put it in the wrong location. If someone can post an example of the correct implementation, we will be very grateful!
My last attempt was to put code that should hide the keyboard in the onDetach () method:
@Override public void onDetach() { super.onDetach(); InputMethodManager imm = (InputMethodManager) this.context.getSystemService(Context.INPUT_METHOD_SERVICE);
android android-softkeyboard android-fragments android-viewpager
Jabari
source share