@Override
  public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    getSupportMenuInflater().inflate(R.menu.extended_search, menu);
    return true;
  }
Example #2
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   menu.findItem(R.id.editBook).setEnabled(false); /* do not allow to edit and add book */
   menu.findItem(R.id.addBook).setEnabled(false);
   return true;
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   getMenuInflater().inflate(R.menu.search, menu);
   MenuItem searchItem = menu.findItem(R.id.menu_search);
   if (searchItem != null && UIUtils.hasHoneycomb()) {
     SearchView searchView = (SearchView) searchItem.getActionView();
     if (searchView != null) {
       SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
       searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
       searchView.setQueryRefinementEnabled(true);
     }
   }
   return true;
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.

    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.

    super.onCreateOptionsMenu(menu);

    final MenuItem searchItem = menu.findItem(R.id.menu_search);
    searchItem.setShowAsAction(
        MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    final SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String s) {
            searchItem.collapseActionView();
            // setCurrentQueryString(s);
            Intent intent = new Intent(MainActivity.this, SearchActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("searchText", s);
            intent.putExtras(bundle);
            startActivity(intent);
            return true;
          }

          @Override
          public boolean onQueryTextChange(String s) {
            Log.e("onQueryTextChange", s);
            return false;
          }
        });
    View searchPlate = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
    if (searchPlate != null) {
      searchPlate.setBackgroundResource(R.color.white);
      TextView searchText =
          (TextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
      if (searchText != null) {
        searchText.setHintTextColor(Color.GRAY);
        searchText.setTextColor(Color.BLACK);
      }
    }
    return true;
  }