android - search listview?
<p>Is it possible with Android to have a search bar for a ListView so that when the search bar is touched a keyboard pops up, and when text is typed into the search bar, the items that match in the ListView are shown?</p>

<p>What I really need is the search bar that brings up a keyboard.</p>

<p>Update:</p>

<p>I've added the EditText field that brings up a keyboard and I can type into the EditText field.  What I want is to have the first few characters of the items in the list shown in the ListView match the characters typed into the EditText window.</p>

<p>I've tried following the approach listed here <a href="http://stackoverflow.com/questions/1737009/answer-to-making-a-nice-looking-listview-filter-on-android/1737042#1737042">ListView Filter</a> but I am a little confused as to how much filtering is already done in ListView?  </p>

<p>1)  Do I need to create a separate array that stores the values that match the text typed into EditText?  From this post <a href="http://stackoverflow.com/questions/3414490/listview-not-updating-after-filtering">Call adapter.notifyDataSetChanged</a>, it appears that ListView already has a shadow array to do this, and it gets updated when adapter.notifyDataSetChanged(); is called.</p>

<p>2)  Do I need to call adapter.notifyDataSetChanged(); to have ListView updated after I type some text in the EditText window?</p>

<p>3)  Do I need to extend ListActivity as this <a href="http://stackoverflow.com/questions/3033791/the-method-setlistadapterarrayadapter-is-undefined-for-the-type-create">post</a> indicates?  If so how do I extend my activity class if the activity class is already being extended from the main activity?</p>

<p>4)  What I currently have is the following:</p>

<pre><code>ArrayAdapter&lt;String&gt; adapter = null;
private EditText filterText = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.symptom);
    ListView symptomList = (ListView) findViewById(R.id.ListView_Symptom);
    symptomList.setTextFilterEnabled(true);
    symptomList.setFastScrollEnabled(true);
    filterText = (EditText) findViewById(R.id.search_box);
    filterText.addTextChangedListener(filterTextWatcher);

    adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.menu_item, symptomsArray);
    symptomList.setAdapter(adapter);

    private TextWatcher filterTextWatcher = new TextWatcher() {

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            adapter.getFilter().filter(s);
            adapter.notifyDataSetChanged();
        }

    };
</code></pre>

<p>Unfortunately at the moment when I type in the EditText box, I get a NullPointer Exception in </p>

<pre><code> Thread [&lt;7&gt; Filter] (Suspended (exception NullPointerException))   
ArrayAdapter$ArrayFilter.performFiltering(CharSequence) line: 437   
Filter$RequestHandler.handleMessage(Message) line: 234  
Filter$RequestHandler(Handler).dispatchMessage(Message) line: 99    
Looper.loop() line: 123 
HandlerThread.run() line: 60    
</code></pre>

<p>Any idea what I am missing?</p>
