I want to hide keyboard on click event of a button. Any help would be appreciated
            Asked
            
        
        
            Active
            
        
            Viewed 1,394 times
        
    2 Answers
11
            to hide the virtual keyboard:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editView.getWindowToken(), 0);
 
    
    
        Nermeen
        
- 15,883
- 5
- 59
- 72
3
            
            
        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.
 
    
    
        KDeogharkar
        
- 10,939
- 7
- 51
- 95
