title: Android adapter.notifyDataSetChanged() not working?
body: <p>I'm writing an app that requires getting input from the user, passing it off to a server, which returns a JSON string, and then displaying its parsed contents in a ListView. I'm currently accomplishing this by extending AsyncTask:</p>
  
  <pre><code>//stripped down version
  public class main extends ListActivity {
  
  ArrayList&lt;String&gt; listItems = new ArrayList&lt;String&gt;();
  ArrayAdapter&lt;String&gt; adapter;
  final EditText input = (EditText)findViewById(R.id.input);
  
  
  input.addTextChangedListener(new TextWatcher() {    
      public void onTextChanged(CharSequence s, int start, int before, int count) {   
              if(!input.getText().toString().equals("")) {
              new GetDataTask().execute(input.getText().toString());
          }
  
      }   
  });
  
  private class GetDataTask extends AsyncTask&lt;String, Void, ArrayList&lt;String&gt;&gt; {
          protected ArrayList&lt;String&gt; doInBackground(String... query) {
  
          URL url = new URL("http://myserversaddressgoeshere.com/search/thequerygoeshere");
          URLConnection conn = url.openConnection();
          BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
              ArrayList&lt;String&gt; items = new ArrayList&lt;String&gt;();
          //the code that parses the JSON goes here; it writes some strings to items
          return items;
          }
  
          protected void onPostExecute(ArrayList&lt;String&gt; items) {
              listItems = items;
          adapter.notifyDataSetChanged();
          }
  }
  
  }
  </code></pre>
  
  <p>(This is my first post so I apologize in advance if my attempt to make that a code block fails)</p>
  
  <p>In the onPostExecute method, after setting listItems equal to items, if I print the contents of listItems, they're exactly what I want. But, for some reason, when executed from onPostExecute, adapter.notifyDataSetChanged() seems to do nothing (when it's called from the main thread, it works fine). </p>
  
  <p>If anyone has any idea of what's going on and/or how to fix it, I'd really appreciate it. Thanks!</p>