title: i want to add a search bar on top of my list view in class (i don't have a layout, i creating the list view in class)
body: <p>for (int i = 1; i &lt;= totalfriends; i++) {</p>
  
  <pre><code>// Cast the integer into a string.
  Integer j = new Integer(i);
  // We need to retrieve the JSONObject but it's first
  // stored in an array.
  JSONArray friendarray = obj.getJSONArray(j.toString());
  JSONObject friendobject = friendarray.getJSONObject(0);
  fname = friendobject.getString("firstname");
  lname = friendobject.getString("lastname");
  uid = friendobject.getString("uid");
  contactNameList.add(fname + " " + lname);
  contactIdList.add(uid);
  // add to arraylist
  //Store the above in a data structure}
  </code></pre>
  
  <p>contactMenu = contactNameList.toArray(new String[contactNameList.size()]);
  idMenu = contactIdList.toArray(new String[contactIdList.size()]);
  contactAdapter = new ArrayAdapter
  
  <pre><code>// After store everything into datastructure, put the code
                  // inside run() and loop again and display the friendlist.
                  runOnUiThread(new Runnable() {
                      public void run() {
                          setListAdapter(contactAdapter);
                          // Here, loop through the data structure and setup
                          // the friend list.
  
                      }
                  });
  </code></pre>