SearchView as part of the AlertDialog
<p>[This is posted on Android Developer's forum as well]</p>

<p>I am trying to place the search widget [<code>SearchView</code> basically] in the
title part of an <code>AlertDialog</code>. Is that allowed, i.e. will it work? The
idea is to have the user enter a search word and when he/she presses
the <kbd>Enter</kbd> key on the keyboard, to use the search word entered to
search through an array of strings and display the result as a
<code>listView</code> in the same <code>AlertDialog</code>'s body portion. The following is the
piece of relevant code.</p>

<pre><code>AlertDialog.Builder dialogBuilder = new
AlertDialog.Builder(MainActivity.this);

RelativeLayout titleLayout = new RelativeLayout(this);
SearchView sv = new SearchView(this);
titleLayout.addView(sv);

dialogBuilder.setCustomTitle(titleLayout);
</code></pre>

<p>When I run this code, I see the search widget in the title alright.
The Virtual/Soft keyboard pops up when I click inside the search box -
but I am unable to type in it because the <code>AlertDialog</code> disappears as
soon as I click anywhere outside of it (as it should). I am wondering
if the keyboard is associated with the activity that is launching the
<code>AlertDialog</code> instead of being in the context of the <code>AlertDialog</code> itself.</p>

<p>Any ideas?</p>

<p>TIA.</p>
