title: Cannot add header view to list -- setAdapter has already been called
body: <p>I have one edittext field and one "search" button. When I click on search, I have to display a list view with data corresponding to the values entered in the edittext. I have added a header to my list using addHeader(). When I do search first time, I am able to display data in List successfully. But when I do search again, I am getting the below error.</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.
  at android.widget.ListView.addHeaderView(ListView.java:261)
  at android.widget.ListView.addHeaderView(ListView.java:284)
  </code></pre>
  
  <p>I have assigned header to my list before setting the adapter.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>myList = (ListView) findViewById(R.id.searchResultsList);
  View header = View.inflate(this, R.layout.search_results_header, null);
  myList.addHeaderView(header, null, false);
  
  dataAdapter = new MyCustomAdapter(this, R.layout.results_list_item, searchedResults);
  myList.setAdapter(dataAdapter);
  </code></pre>
  
  <p>Where I am doing wrong?</p>