title: Filter list view from edit text
body: <p>I have an edit text as a search bar and a list view that filters the text that I typed but unfortunately, it doesn't filter the list view. I have used an customize array adapter with object Friend. <strong>Friend object has name, address and phone number</strong> but I only want to filter its name. In my activity...</p>
  
  <pre><code>searchBarTextView.addTextChangedListener(new TextWatcher() {
  @Override
  public void onTextChanged(CharSequence s, int start, int before, int count) {
      friendListAdapter.getFilter().filter(s);
  }}
  </code></pre>
  
  <p>While in adapter...</p>
  
  <p><pre>
      @Override
      public Filter getFilter() {
          Log.d(TAG, "begin getFilter");
          if(newFilter == null) {
              newFilter = new Filter() {
                  @Override
                  protected void publishResults(CharSequence constraint, FilterResults results) {
                      // TODO Auto-generated method stub
                      Log.d(TAG, "publishResults");
                      notifyDataSetChanged();
                  }</p>
  
  <code>            @Override
              protected FilterResults performFiltering(CharSequence constraint) {
                  Log.d(TAG, "performFiltering");
  
                  constraint = constraint.toString().toLowerCase();
                  Log.d(TAG, "constraint : "+constraint);
  
                  List&lt;ChatObject&gt; filteredFriendList = new LinkedList&lt;ChatObject&gt;();
  
                  for(int i=0; i&lt;friendList.size(); i++) {
                      Friend newFriend = friendList.get(i);
                      Log.d(TAG, "displayName : "+newFriend.getDisplayName().toLowerCase());
                      if(newFriend.getDisplayName().toLowerCase().contains(constraint)) {
                          Log.d(TAG, "equals : "+newFriend.getDisplayName());
                          filteredFriendList.add(newFriend);
                      }
                  }
  
                  FilterResults newFilterResults = new FilterResults();
                  newFilterResults.count = filteredFriendList.size();
                  newFilterResults.values = filteredFriendList;
                  return newFilterResults;
              }
          };
      }
      Log.d(TAG, "end getFilter");
      return newFilter;
  }
  </code></pre>
  
  <p></p>
  
  <p>Could someone please help me how to correctly show the filtered array adapter? I think the notifyDataSetChanged is not invoked. Thanks.</p>