title: Searchview with ListView will not work
body: <p>I am working on a project that creates a list view of notes. I tried to implement a search view so I could allow the user to filter the created notes. I am having trouble figuring out what I am doing wrong. I have looked at every post I could find, and walk through every tutorial. I just cannot get it. Whenever I type anything into the search view, everything is filtered away. Any help would be greatly appreciated. </p>
  
  <p>My MainActivity class</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity  {
  
      NoteAdaptor na;
      ArrayList&lt;Note&gt; notes;
      SearchView searchView;
  
      private ListView nListViewNotes;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          nListViewNotes = (ListView) findViewById(R.id.mainListViewNotes);
  
          notes = Utilities.getAllSavedNotes(this);
  
          na = new NoteAdaptor(this, R.layout.item_note, notes);
          nListViewNotes.setAdapter(na);
  
          searchView = (SearchView) findViewById(R.id.searchView);
  
          searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
              @Override
              public boolean onQueryTextSubmit(String query) {
                  return false;
              }
  
              @Override
              public boolean onQueryTextChange(String newText) {
                  na.getFilter().filter(newText);
                  return false;
              }
          });        
      }
  
      @Override
      //adds the "+" to the menu
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch(item.getItemId()){
              case R.id.action_main_new_note:
                  //start NoteActivity in NewNote mode
                  Intent newNoteActivity = new Intent(this, NoteActivity.class);
                  startActivity(newNoteActivity);
                  break;
          }
          return true;
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          nListViewNotes.setAdapter(null);
  
          notes = Utilities.getAllSavedNotes(this);
  
          if(notes == null || notes.size() ==0){
              Toast.makeText(this, "You have no notes saved!", Toast.LENGTH_SHORT).show();
              return;
          }else{
  
               na = new NoteAdaptor(this, R.layout.item_note, notes);
               nListViewNotes.setAdapter(na);
  
              //gets the file based what posistion the user clicked on
              nListViewNotes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                      String fileName = ((Note) nListViewNotes.getItemAtPosition(position)).getnDateTime()
                              + Utilities.FILE_EXTENSION;
  
                      Intent viewNoteIntent = new Intent(getApplicationContext(), NoteActivity.class);
                      viewNoteIntent.putExtra("NOTE_FILE", fileName);
                      startActivity(viewNoteIntent);
                  }
              });
          }
      }
  }
  </code></pre>
  
  <p>My note class</p>
  
  <pre><code>public class Note implements Serializable{
      private long nDateTime;
      private String nTitle;
      private String nContent;
      private ArrayList nMentions;
      private ArrayList nTopics;
      private ArrayList nIDs;
      private ArrayList nRefs;
  
      public Note(long DateTime, String Title, String Content, ArrayList&lt;String&gt; Mentions, ArrayList&lt;String&gt; Topics, ArrayList&lt;String&gt; IDs
              ,ArrayList&lt;String&gt; Refs) {
          nDateTime = DateTime;
          nTitle = Title;
          nContent = Content;
          nMentions = Mentions;
          nTopics = Topics;
          nIDs = IDs;
          nRefs = Refs;
      }
  
      public long getnDateTime() {
          return nDateTime;
      }
  
      public String getnTitle() {
          return nTitle;
      }
  
      public String getnContent() {
          return nContent;
      }
  
      public ArrayList&lt;String&gt; getnMentions() { return nMentions; }
  
      public ArrayList&lt;String&gt; getnTopics() { return nTopics; }
  
      public ArrayList&lt;String&gt; getnIDs() { return nIDs; }
  
      public ArrayList&lt;String&gt; getnRefs() { return nRefs; }
  
      public void setnDateTime(long nDateTime) {
          this.nDateTime = nDateTime;
      }
  
      public void setnTitle(String nTitle) {
          this.nTitle = nTitle;
      }
  
      public void setnContent(String nContent) {
          this.nContent = nContent;
      }
  
      public void setnMentions(ArrayList&lt;String&gt; nMentions) { this.nMentions = nMentions; }
  
      public void setnTopics(ArrayList&lt;String&gt; nTopics) { this.nTopics = nTopics; }
  
      public String getDateTimeAsString(Context context){
          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", context.getResources().getConfiguration().locale);
          sdf.setTimeZone(TimeZone.getDefault());
  
          return sdf.format(new Date(nDateTime));
      }
  }
  </code></pre>
  
  <p>Note Adapter class</p>
  
  <pre><code>public class NoteAdaptor extends ArrayAdapter&lt;Note&gt; implements Filterable{
  
      private ArrayList notes = null;
      private ArrayList&lt;Note&gt; arraylist;
      Context mContext;
      LayoutInflater inflater;
  
  
      public NoteAdaptor(@NonNull Context context, @LayoutRes int resource, @NonNull ArrayList&lt;Note&gt; notes) {
          super(context, resource, notes);
          mContext = context;
          this.notes = notes;
          inflater = LayoutInflater.from(mContext);
          this.arraylist = new ArrayList&lt;&gt;();
          this.arraylist.addAll(notes);
      }
  
      @NonNull
      @Override
      public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
  
          if (convertView == null){
              convertView = LayoutInflater.from(getContext())
                      .inflate(R.layout.item_note, null);
          }
  
          Note note = getItem(position);
  
          if (note!= null){
              TextView title =  (TextView) convertView.findViewById(R.id.list_note_title);
              TextView date =  (TextView) convertView.findViewById(R.id.list_note_date);
              TextView content =  (TextView) convertView.findViewById(R.id.list_note_content);
  
              title.setText(note.getnTitle());
              date.setText(note.getDateTimeAsString(getContext()));            
  
              //in case the note is very long, we only preview a substring of that note
              if (note.getnContent().length() &gt; 50){
                  content.setText(note.getnContent().substring(0, 50));
              }else{
                  content.setText(note.getnContent());
              }         
          }
          return convertView;
      }
  
      public void filter(String charText) {
          charText = charText.toLowerCase(Locale.getDefault());
          notes.clear();
          if (charText.length() == 0) {
              notes.addAll(arraylist);
          } else {
              for (Note note : arraylist) {
                  if (note.getnContent().toLowerCase(Locale.getDefault()).contains(charText) ||
                          note.getnTitle().toLowerCase(Locale.getDefault()).contains(charText)) {
                      notes.add(note);
                  }
              }
          }
          notifyDataSetChanged();
      }
  }
  </code></pre>
  
  <p>Main xml</p>
  
  <pre><code>tools:context="com.brendan.notetakinghw2.MainActivity"&gt;
  
  &lt;SearchView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/searchView" /&gt;
  
  &lt;ListView
      android:id="@+id/mainListViewNotes"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentStart="true"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/searchView" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Activity_Note xml</p>
  
  <p>
  
  <pre><code>xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.brendan.notetakinghw2.NoteActivity"&gt;
  
  &lt;EditText
      android:id="@+id/noteTitle"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:ems="10"
      android:hint="Title:"
      android:inputType="textPersonName"
      android:maxLines="1"
      android:singleLine="true" /&gt;
  
  
  &lt;EditText
      android:id="@+id/noteContent"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:ems="10"
      android:gravity="top"
      android:hint="Enter your note here"
      android:inputType="textMultiLine"
      android:layout_alignParentStart="true"
      android:layout_below="@+id/noteTitle"
      android:layout_above="@+id/mentions" /&gt;
  
  &lt;TextView
      android:id="@+id/mentions"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
  
      android:layout_above="@+id/topics"
      android:layout_alignParentStart="true" /&gt;
  
  &lt;TextView
      android:id="@+id/topics"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
  
      android:layout_above="@+id/identifiers"
      android:layout_alignParentStart="true" /&gt;
  
  &lt;TextView
      android:id="@+id/identifiers"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
  
      android:layout_above="@+id/refrences"
      android:layout_alignParentStart="true" /&gt;
  
  &lt;TextView
      android:id="@+id/refrences"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
  
      android:layout_alignParentBottom="true"
      android:layout_alignParentStart="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Item_note xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;TextView
      android:id="@+id/list_note_title"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceLarge"
      tools:text="TITLE" /&gt;
  
  &lt;TextView
      android:id="@+id/list_note_date"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceSmall"
      tools:text="11/11/1111" /&gt;
  
  &lt;TextView
      android:id="@+id/list_note_content"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceMedium"
      tools:text="CONTENT" /&gt;
  
  &lt;!--&lt;TextView
      android:id="@+id/list_note_mentions"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceMedium"
      tools:text="MENTIONS" /&gt;
  
  &lt;TextView
      android:id="@+id/list_note_topics"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceMedium"
      tools:text="TOPICS"/&gt;--&gt;
  </code></pre>
  
  <p></p>