Programmatically Hide Soft Keyboard in ViewPager.OnPageChangeListener onPageSelected()?

后端 未结 5 966
醉酒成梦
醉酒成梦 2021-02-02 09:39

I have a ViewPager + ActionBar with tabs. I want to make the soft keyboard hide when I \"swipe\" to another tab but I can\'t figure out how.

I\'ve passed in my Activity

5条回答
  •  猫巷女王i
    2021-02-02 10:30

    Simple way :

    InputMethodManager imm = (InputMethodManager)    
    getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    

提交回复
热议问题