title: Validate text input in SearchView
body: <p>I have a SearchView in ActionBar.</p>
  
  <p>I'd like to validate the text input by the user before submitting it to SearchManager.</p>
  
  <p>What I mean is, if a user entered text less than 3 characters, then a Toast will pop up instead going to another activity that shows the search results.</p>
  
  <p>Here is how I implement the SearchView:</p>
  
  <p>In <code>MainActivity</code>:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.search, menu);
  
      SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
      SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
      searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  
      SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String s) {
              Log.d(TAG, "submit= "+s);
              if (s.length() &lt; 4) Toast.makeText(getApplicationContext(), "More than 3 letter pl0x", Toast.LENGTH_LONG).show();
              return true;
          }
  
          @Override
          public boolean onQueryTextChange(String s) {
              return true;
          }
      };
      searchView.setOnQueryTextListener(queryTextListener);
  
      return super.onCreateOptionsMenu(menu);
  }
  </code></pre>
  
  <p>I just wanna make sure the user input is more than 3 characters. Is there a possible way to do this?</p>