title: Android Handler to refresh GUI
body: <p>I am trying to create a UI Handler to refresh the gridview after i execute the parseURL ASyncTask class and return an Arraylist  back to the MainActivity to print out on the gridview. </p>
  
  <p>The code i have compiles and run without any errors but the gridview does not refresh after clicking the button. In the debugger it shows that the parseURL class is successfully returning the list and the handler message has a <code>what</code> value of 1. However the handler does not seem to work.</p>
  
  <p>Main Activity Class</p>
  
  <pre><code>private final Handler handler = new Handler() {
      public void handleMessage(Message msg) {
          if(msg.what == 1) {
              List&lt;String&gt; list = (List) msg.obj;
              updateUI(list);
          }
      }
  }
  
  public void onButtonClick(View v) {
      EditText text = (EditText)findViewById(R.id.editText1);
      String id = text.getText().toString();
  
      new parseURL() {
          @Override
          protected void onPostExecute(List&lt;String&gt; list) {
              handler.obtainMessage(1, list);
          }
      }
  }
  
  private void updateUI(List&lt;String&gt; list) {
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, list);
  
      GridView grid = (GridView)findViewById(R.id.gridView1);
      grid.setAdapter(adapter);
      adapter.notifyDataSetChanged();
      //grid.invalidateViews();
  }
  </code></pre>