title: Is there any listener on Android SearchView to notify if SearchView is expanded and ready to take input?
body: <p>I want to show some default suggestions in SearchView when User hasn't typed anything. 
  I am setting my custom suggestion adapter manually using matrix cursor. I tried setting adapter in onFocusChange and onClickListner but suggestions get hidden behind a keyboard, apparently suggestions are loading earlier than keyboard.
  I did not find any listener which tells me that searchview is completely loaded with keyboard in the view.
  Help me in finding the right solution or any workaround. I have tried a workaround postDelayed but it's not smooth experience.</p>
  
  <p>I have this code inside onCreateOptionsMenu</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      menu.clear();
      final MenuInflater inflater = this.getMenuInflater();
      inflater.inflate(R.menu.searchview_in_menu, menu);
      this.menu=menu;
      basketProductCount = ShoppinglistDataSource.get(getContext()).getProductCountToOrder();
      if(basketProductCount&gt;0 &amp;&amp; menu!=null){
          this.activateBasket();
      }
  
      SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE);
      MenuItem searchMenuItem = menu.findItem(R.id.action_search);
      mSearchView = (SearchView) searchMenuItem.getActionView();
  
      if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
  
          int searchButtonId = mSearchView.getContext().getResources().getIdentifier("android:id/search_button", null, null);
          ImageView searchButton = (ImageView) mSearchView.findViewById(searchButtonId);
          if(searchButton!=null)
              searchButton.setImageResource(R.drawable.search);
  
  
  
          mSearchView.setSearchableInfo(manager.getSearchableInfo(new ComponentName(getApplicationContext(), SearchProductActivity.class)));
          mSearchView.setIconifiedByDefault(true);
          mSearchView.setIconified(true);
          mSearchView.setQueryHint("Search from 4000+ products");
          mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
  
              @Override
              public boolean onQueryTextSubmit(String s) {
                  Log.d("SEARCH_VIEW_DEBUG","Inside onQueryTextSubmit for query: "+s);
                  mSearchView.clearFocus();
                  mSearchView.setIconified(true);
                  //return false to let the SearchView perform the default action
                  return false;
              }
  
              @Override
              public boolean onQueryTextChange(String query) {
                  query = query.toLowerCase().trim();
                  Log.d("Query changed to ",query);
                  if (query.length() &gt; 1) {
                      Bundle b = new Bundle();
                      b.putString("query",query);
                      if(getLoaderManager().getLoader(1)!=null)
                          getLoaderManager().restartLoader(1, b, suggestionLoaderCallback);
                      else
                          getLoaderManager().initLoader(1, b, suggestionLoaderCallback);
                  }
                  return true;
              }
  
          });
  
          mSearchView.setOnQueryTextFocusChangeListener(new SearchView.OnFocusChangeListener() {
  
              @Override
              public void onFocusChange(View view, boolean queryTextFocused) {
                  Log.d("DEBUGGIN", "onFocusChange");
                  if(!queryTextFocused) {
                      if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                          mSearchView.onActionViewCollapsed();
                          mSearchView.clearFocus();
                      }
                  } else {
                      /**This is doing the trick, but not smooth experience**/
                /**also suggestions may get behind the keyboard if keyboard takes time to pop up**/
                      view.postDelayed(new Runnable() {
                          @Override
                          public void run() {
  
                              if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                                  mSearchView.onActionViewExpanded();
                                  Log.d("DEBUGGIN", "Inside expand");
                                  if (mSearchView.getQuery().length() == 0) {
  
                                      Log.d("DEBUGGIN", "getting default suggestions");
                                      sug.clear();
                                      sug.add("Personal Care");
                                      sug.add("Oil");
                                      sug.add("Spices");
                                      sug.add("Breakfast");
                                      sug.add("Snacks");
                                      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
                                          String[] columns = new String[]{"_id", "text"};
                                          Object[] temp = new Object[]{0, "default"};
                                          final MatrixCursor cursor = new MatrixCursor(columns);
                                          int i = 0;
                                          for (i = 0; i &lt; sug.size(); i++) {
                                              if (!sug.get(i).equals("")) {
                                                  temp[0] = i;
                                                  temp[1] = sug.get(i);
                                                  cursor.addRow(temp);
                                              }
                                          }
                                          Log.d("Initial categories", sug.toString());
                                          mSearchView.setSuggestionsAdapter(new CustomSuggestionAdapter(ListAll.this, cursor, sug));
                                          mSearchView.getSuggestionsAdapter().notifyDataSetChanged();
                                          mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
                                              @Override
                                              public boolean onSuggestionSelect(int i) {
                                                  Log.d("SEARCH_VIEW_DEBUG", "Inside onSuggestionSelect");
  
  
  
                                                  return false;
                                              }
  
                                              @Override
                                              public boolean onSuggestionClick(int i) {
                                                  Log.d("SEARCH_VIEW_DEBUG", "Inside onSuggestionClick");
                                                  MatrixCursor cursor = (MatrixCursor) mSearchView.getSuggestionsAdapter().getItem(i);
                                                  String suggest1 = cursor.getString(cursor
                                                          .getColumnIndex("text"));
                                                  Log.d("Clicked Item", suggest1);
                                                  mSearchView.setQuery(suggest1, true);
                                                  return true;
                                              }
                                          });
                                      }
                                  }
                              }
  
                          }
                      }, 600);
                  }
              }
          });
      }
  
      if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
          searchMenuItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
              @Override
              public boolean onMenuItemActionExpand(MenuItem item) {
                  /**This never gets called**/
                  Log.d("DEBUGGIN", "Inside onMenuItemActionExpand");
                  return true;
              }
  
              @Override
              public boolean onMenuItemActionCollapse(MenuItem item) {
                  /**This never gets called**/
                  Log.d("DEBUGGIN", "Inside onMenuItemActionCollapse");
                  return true;
              }
          });
      } else {
          MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() {
  
              @Override
              public boolean onMenuItemActionExpand(MenuItem item) {
                  /**This never gets called**/
                  Log.d("DEBUGGIN", "Inside MenuItemCompat onMenuItemActionExpand");
                  return true;
              }
  
              @Override
              public boolean onMenuItemActionCollapse(MenuItem item) {
                  /**This never gets called**/
                  Log.d("DEBUGGIN", "Inside MenuItemCompat onMenuItemActionCollapse");
                  return true;
              }
          });
      }
  
      //return true onCreateOptionsMenu
      return true;
  }
  </code></pre>