title: Android: How to implement a SearchView with sections so as to search across multiple lists
body: <p>I am trying to implement a searchView in my app that enables the user to search a text across multiple lists. Something like below:</p>
  
  <p><a href="https://i.stack.imgur.com/u05eY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u05eY.png" alt="enter image description here"></a></p>
  
  <p>So far I have been able to implement a searchView that searches for text across a single list and it works great, but I can't think of a way to make it work across multiple lists with the section headers showing.</p>
  
  <pre><code>    @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.menu_main, menu);
  
          item = menu.findItem(R.id.action_search);
  
          searchView = (SearchView) MenuItemCompat.getActionView(item);
  
          SearchManager searchManager =
                  (SearchManager) getSystemService(Context.SEARCH_SERVICE);
          searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
          searchView.setSuggestionsAdapter(mAdapter);
  
          searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
              @Override
              public boolean onSuggestionSelect(int position) {
                  return false;
              }
  
              @Override
              public boolean onSuggestionClick(int position) {
  //           some code here     
                  return true;
              }
          });
  
          searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
              @Override
              public boolean onQueryTextSubmit(String query) {
                  return false;
              }
  
              @Override
              public boolean onQueryTextChange(String query) {
                  populateAdapter(query);
                  return true;
              }
          });
  //        return true;
          return true;
      }
  
  private void populateAdapter(String query) {
          final MatrixCursor c = new MatrixCursor(new String[]{BaseColumns._ID, "cityName", "country"});
          for (City city: list) {
              if (city.getTitle().toLowerCase().startsWith(query.toLowerCase()))
                  c.addRow(new Object[]{city.getID(), city.getTitle(), city.getNation()});
          }
          mAdapter.changeCursor(c);
      }
  </code></pre>
  
  <p>Any help would be appreciated, Thanks !!</p>