Android hide keyboard on btn click

This question already has an answer here:

  • Close/hide the Android Soft Keyboard 69 answers

  • 隐藏虚拟键盘:

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

    InputMethodManager inputManager = (InputMethodManager)
                                      getSystemService(Context.INPUT_METHOD_SERVICE); 
    
    inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                                         InputMethodManager.HIDE_NOT_ALWAYS);
    

    I put this right after the onClick(View v) event. You need to import android.view.inputmethod.InputMethodManager;

    The keyboard hides when you click the button.

    链接地址: http://www.djcxy.com/p/16606.html

    上一篇: 软输入键盘在Android中不可见

    下一篇: Android在btn点击隐藏键盘