Android: EditText and Button; when click Button, unfocus EditText and hide soft keyboard?
<pre><code>&lt;EditText android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:layout_weight="1"
    android:id="@+id/name" android:singleLine="true"
    android:maxLength="12" android:capitalize="none" android:inputType="text" /&gt;
&lt;Button android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/search_button"
    android:text="Search" /&gt;
</code></pre>

<p>I have this at the top of my application. When the application starts, the EditText is orange highlighted and has a cursor in it; when the EditText is tapped, the soft keyboard pops up. The user uses it to type into the EditText.</p>

<p>However, when they click the Button, my onClick method fires and does everything it's supposed to, however the soft keyboard stays on screen and the EditText is still highlighted with its cursor.</p>

<p>I also have, at the top of the Button onclick:</p>

<pre><code>findViewById(R.id.name).clearFocus();
</code></pre>

<p>In spite of this, the EditText does not seem to clear its focus. How do I make the button actually act as if it is submitting the form?</p>

<p>Also, I do not transition to a different Activity on the click of the Button. I suppose that is the typical case, and probably the reason why they don't bother hiding the keyboard. However I want to keep the search box and button at the top of the screen, so I just dynamically fill and add views to the screen when the Button is pressed.</p>

<p>How can I achieve my desired behavior?</p>
