Esempio n. 1
0
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 private void setupSearchMenuItem(Menu 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()));
     }
   }
 }
Esempio n. 2
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_search:
       if (!UIUtils.hasHoneycomb()) {
         startSearch(null, false, Bundle.EMPTY, false);
         return true;
       }
       break;
   }
   return super.onOptionsItemSelected(item);
 }
 @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 onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        if (mSlidingPaneLayout.isSlideable() && !mSlidingPaneLayout.isOpen()) {
          // If showing the detail view, pressing Up should show the master pane.
          mSlidingPaneLayout.openPane();
          return true;
        }
        break;

      case R.id.menu_search:
        if (!UIUtils.hasHoneycomb()) {
          startSearch(null, false, Bundle.EMPTY, false);
          return true;
        }
        break;
    }
    return super.onOptionsItemSelected(item);
  }