title: Updating list view in android using ArrayAdapter with runOnUiThread
body: <p>Where do I place the ArrayAdapter exactly? I'm a newbie. I'm getting an error saying: The constructor ArrayAdapter(new Runnable(){}, int, int, ArrayList>).
  Code equivalent to the commented section with SimpleArray has to written.</p>
  
  <pre><code>public class SearchEventsActivity extends ListActivity {
  
  // Progress Dialog
  private ProgressDialog pDialog;
  EditText inputSearch;
  
  
  // Creating JSON Parser object
  JSONParser jParser = new JSONParser();
  
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; eventsList;
  ListView lv;
  
  // url to get all events list
  private static String url_all_events = "http://10.0.2.2/indiJam/search_all_events.php";
  
  // JSON Node names
  private static final String TAG_SUCCESS = "success";
  private static final String TAG_EVENTS = "events";
  private static final String TAG_NAME = "event_name";
  private static final String TAG_DATE = "date";
  private static final String TAG_LOCATION = "location";
  private static final String TAG_CATEGORY = "category";
  
  // products JSONArray
  JSONArray events = null;
  ArrayAdapter&lt;String&gt; adapter;
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.search);
  
      // Hashmap for ListView
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; eventsList;
  
  
  
  
  
  
      // Loading products in Background Thread
      new LoadAllEvents().execute();
  }
  
  
  /**
   * Background Async Task to Load all product by making HTTP Request
   * */
  class LoadAllEvents extends AsyncTask&lt;String, String, String&gt; {
  
      /**
       * Before starting background thread Show Progress Dialog
       * */
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          pDialog = new ProgressDialog(SearchEventsActivity.this);
          pDialog.setMessage("Loading events...");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(false);
          pDialog.show();
      }
  
      /**
       * getting All events from url
       * */
      protected String doInBackground(String... args) {
          // Building Parameters
          List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
          // getting JSON string from URL
          JSONObject json = jParser.makeHttpRequest(url_all_events, "GET", params);
  
          // Check your log cat for JSON reponse
          Log.d("All Events: ", json.toString());
  
          try {
              // Checking for SUCCESS TAG
              int success = json.getInt(TAG_SUCCESS);
  
              if (success == 1) {
                  // events found
                  // Getting Array of Events
                  events = json.getJSONArray(TAG_EVENTS);
  
                  // looping through All Products
                  for (int i = 0; i &lt; events.length(); i++) {
                      JSONObject c = events.getJSONObject(i);
  
                      // Storing each json item in variable
  
                      String name = c.getString(TAG_NAME);
                      String date = c.getString(TAG_DATE);
                      String location = c.getString(TAG_LOCATION);
                      String category = c.getString(TAG_CATEGORY);
                      // URL decoding
                      name = name.replace("+", " ");
                      name = name.replace("%27", "\'");
  
                      category = category.replace("+", " ");
                      category = category.replace("%27", "\'");
  
                      location = location.replace("+", " ");
                      location = location.replace("%27", "\'");
                      // Adding headers
                      date = "On: " + date;
                      location = "At: " + location;
                      category = "Under: " + category;
  
                      // creating new HashMap
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      // adding each child node to HashMap key =&gt; value
  
                      map.put(TAG_NAME, name);
                      map.put(TAG_DATE, date);
                      map.put(TAG_LOCATION, location);
                      map.put(TAG_CATEGORY, category);
  
                      // adding HashList to ArrayList
                      eventsList.add(map);
                  }
              } 
              else 
              {
                  // no products found
                  // Launch Add New product Activity
                  Intent i = new Intent(getApplicationContext(),
                          CreateEventActivity.class);
                  // Closing all previous activities
                  i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                  startActivity(i);
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          return null;
      }
  
      /**
       * After completing background task Dismiss the progress dialog
       * **/
      protected void onPostExecute(String file_url) {
          // dismiss the dialog after getting all products
          pDialog.dismiss();
          // updating UI from Background Thread
          runOnUiThread(new Runnable() {
              public void run() {
                  /**
                   * Updating parsed JSON data into ListView
                   * */
                  /*
                  ListAdapter adapter = new SimpleAdapter(
                          SearchEventsActivity.this, eventsList,
                          R.layout.list_item, new String[] {
                                  TAG_NAME,TAG_DATE,TAG_LOCATION,TAG_CATEGORY},
                          new int[] {R.id.name,R.id.date,R.id.location,R.id.category });
                  // updating listview
                  setListAdapter(adapter);
                  */
                  //adapter = new ArrayAdapter&lt;String&gt;(SearchEventsActivity.this, R.layout.list_item, R.id.name, eventsList);
  
                  ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                            R.layout.list_item, R.id.name, eventsList);
  
                  inputSearch = (EditText) findViewById(R.id.inputSearch);
                  inputSearch.addTextChangedListener(new TextWatcher() {
  
                      @Override
                      public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
                          // When user changed the Text
                          ((ArrayAdapter&lt;?&gt;)SearchEventsActivity.this.adapter).getFilter().filter(cs);   
                      }
  
                      @Override
                      public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                              int arg3) {
                          // TODO Auto-generated method stub
  
                      }
  
                      @Override
                      public void afterTextChanged(Editable arg0) {
                          // TODO Auto-generated method stub                          
                      }
                  });
  
                  }
              });
  
          }
  
      }
  }
  </code></pre>