How to hide default keyboard when click on menu?
<p>I have tried several methods for this website by inserting the code in the <code>onCreateOptionsMenu (Menu menu)</code> without success. I want to hide the keyboard when I click the menu button.</p>

<p>I have three EditText where I write some data, and options to insert / delete / modify a database, are on the menu, but if I click, the keyboard does not hide automatically.</p>

<p>I have something like this:</p>

<pre><code>    @Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);

    if(this.getCurrentFocus() != null &amp;&amp; this.getCurrentFocus() instanceof EditText){
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
    return true;
}
</code></pre>

<p>It only works the first time I press the menu button.</p>

<p>Thanks!</p>
