@TargetApi(11)
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_item_new_crime:
       Crime crime = new Crime();
       CrimeLab.get(getActivity()).addCrime(crime);
       Intent i = new Intent(getActivity(), CrimeActivity.class);
       i.putExtra(CrimeFragment.EXTRA_CRIME_ID, crime.getId());
       startActivityForResult(i, 0);
       return true;
     case R.id.menu_item_show_subtitle:
       if (getActivity().getActionBar().getSubtitle() == null) {
         getActivity().getActionBar().setSubtitle(R.string.subtitle);
         mSubtitleVisible = true;
         item.setTitle(R.string.hide_subtitle);
       } else {
         getActivity().getActionBar().setSubtitle(null);
         mSubtitleVisible = false;
         item.setTitle(R.string.show_subtitle);
       }
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
示例#2
1
    @Override
    public boolean onContextItemSelected(MenuItem item) {

      int posn = (int) ((AdapterContextMenuInfo) item.getMenuInfo()).position;
      Codec c = codecs.elementAt(posn);
      if (item.getItemId() == MENU_UP) {
        if (posn == 0) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn - 1);
        codecs.set(posn - 1, c);
        codecs.set(posn, tmp);
      } else if (item.getItemId() == MENU_DOWN) {
        if (posn == codecs.size() - 1) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn + 1);
        codecs.set(posn + 1, c);
        codecs.set(posn, tmp);
      }
      PreferenceScreen ps = getPreferenceScreen();
      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
      String v = "";
      SharedPreferences.Editor e = sp.edit();

      for (Codec d : codecs) v = v + d.number() + " ";
      e.putString(Settings.PREF_CODECS, v);
      e.commit();
      ps.removeAll();
      addPreferences(ps);
      return super.onContextItemSelected(item);
    }
 /** Creates and returns a menu button for the specified menu item. */
 private static Button createMenuItemButton(Context context, MenuItem menuItem) {
   Button menuItemButton =
       (Button) LayoutInflater.from(context).inflate(R.layout.floating_popup_menu_button, null);
   menuItemButton.setText(menuItem.getTitle());
   menuItemButton.setContentDescription(menuItem.getTitle());
   return menuItemButton;
 }
示例#4
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camara) {
      // Handle the camera action
      Intent intent = new Intent(MainActivity.this, DetailActivity.class);
      startActivity(intent);
      item.setChecked(false);
    } else if (id == R.id.nav_gallery) {
      Intent intent = new Intent(MainActivity.this, RoutinNaviActivity.class);
      startActivity(intent);
      item.setChecked(false);
    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   super.onCreateOptionsMenu(menu, inflater);
   MenuItem menuItem = menu.add(mSettingsTitle);
   menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
   menuItem.setIntent(mSettingsIntent);
 }
示例#6
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    // make non-clickable
    tts = menu.findItem(R.id.menu_speech_to_text);
    tts.setVisible(false);
    tts.setEnabled(false);

    // NOTE: only works on API 11
    final MenuItem menuSearch = menu.findItem(R.id.menu_search);

    mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    mSearchView.setQueryHint("Search for a Product.");
    mSearchView.setOnQueryTextListener(
        new OnQueryTextListener() {

          @Override
          public boolean onQueryTextSubmit(String query) {
            search(query);
            return true;
          }

          @Override
          public boolean onQueryTextChange(String newText) {
            return false;
          }
        });
    return true;
  }
示例#7
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_words, menu);

    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    MenuItemCompat.setOnActionExpandListener(
        searchMenuItem,
        new MenuItemCompat.OnActionExpandListener() {
          @Override
          public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
          }

          @Override
          public boolean onMenuItemActionCollapse(MenuItem item) {
            updateData();
            return true;
          }
        });

    mSearchView = (SearchView) searchMenuItem.getActionView();
    mSearchView.setQueryHint(getString(R.string.search_hint));

    if (mFilterText != null) {
      String query = mFilterText;
      searchMenuItem.expandActionView();
      mSearchView.setQuery(query, true);
      mSearchView.clearFocus();
    }
    setSearchViewTextChangeListener();
  }
 @Override
 public boolean onContextItemSelected(android.view.MenuItem item) {
   if (!(item.getMenuInfo() instanceof AdapterContextMenuInfo))
     return super.onContextItemSelected(item);
   Log.d(TAG, "Context menu called");
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
   switch (item.getItemId()) {
     case R.id.add_to_watch:
       /*
        * Implement code to toggle watch of this novel
        */
       if (info.position > -1) {
         PageModel novel = listItems.get(info.position);
         if (novel.isWatched()) {
           novel.setWatched(false);
           Toast.makeText(
                   getSherlockActivity(),
                   "Removed from watch list: " + novel.getTitle(),
                   Toast.LENGTH_SHORT)
               .show();
         } else {
           novel.setWatched(true);
           Toast.makeText(
                   getSherlockActivity(),
                   "Added to watch list: " + novel.getTitle(),
                   Toast.LENGTH_SHORT)
               .show();
         }
         NovelsDao.getInstance(getSherlockActivity()).updatePageModel(novel);
         adapter.notifyDataSetChanged();
       }
       return true;
     case R.id.download_novel:
       /*
        * Implement code to download novel synopsis
        */
       if (info.position > -1) {
         PageModel novel = listItems.get(info.position);
         ArrayList<PageModel> novels = new ArrayList<PageModel>();
         novels.add(novel);
         touchedForDownload = novel.getTitle() + "'s information";
         executeDownloadTask(novels);
       }
       return true;
     case R.id.delete_novel:
       if (info.position > -1) {
         toggleProgressBar(true);
         PageModel novel = listItems.get(info.position);
         boolean result = NovelsDao.getInstance(getSherlockActivity()).deleteNovel(novel);
         if (result) {
           listItems.remove(novel);
           adapter.notifyDataSetChanged();
         }
         toggleProgressBar(false);
       }
       return true;
     default:
       return super.onContextItemSelected(item);
   }
 }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.layout_apps_list) {
      final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
      Application app = listApps.get(info.position);
      if (app.getName() == null) {
        menu.setHeaderTitle("Unknown application");
      } else {
        menu.setHeaderTitle(app.getName());
      }
      MenuItem menuItem = menu.add(Menu.NONE, MENUITEM_DETAILS, MENUITEM_DETAILS, "Details");
      menuItem.setOnMenuItemClickListener(
          new OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
              editApplication(info.position);
              return true;
            }
          });
      menuItem = menu.add(Menu.NONE, MENUITEM_DELETE, MENUITEM_DELETE, "Delete");
      menuItem.setOnMenuItemClickListener(
          new OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
              deleteApplication(info.position);
              return true;
            }
          });
    }
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    if (PhoneConfiguration.getInstance().HandSide == 1) { // lefthand
      int flag = PhoneConfiguration.getInstance().getUiFlag();
      if (flag == 1 || flag == 3 || flag == 5 || flag == 7) { // 文章列表,UIFLAG为1或者1+2或者1+4或者1+2+4
        inflater.inflate(R.menu.articlelist_menu_left, menu);
      } else {
        inflater.inflate(R.menu.articlelist_menu, menu);
      }
    } else {
      inflater.inflate(R.menu.articlelist_menu, menu);
    }
    final int flags = ThemeManager.ACTION_BAR_FLAG;

    MenuItem lock = menu.findItem(R.id.article_menuitem_lock);
    int orentation = ThemeManager.getInstance().screenOrentation;
    if (orentation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
        || orentation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
      lock.setTitle(R.string.unlock_orientation);
      lock.setIcon(R.drawable.ic_menu_always_landscape_portrait);
    }

    ReflectionUtil.actionBar_setDisplayOption(this, flags);
    return super.onCreateOptionsMenu(menu);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.principal.novo) {
      Toast.makeText(ListaAluno.this, "Você clicou no menu \"Novo\"", Toast.LENGTH_SHORT).show();

      Intent i = new Intent(this, Formulario.class);

      startActivity(i);
    }

    if (item.getItemId() == R.principal.galeria) {
      Toast.makeText(ListaAluno.this, "Você clicou no menu \"Galeria\"", Toast.LENGTH_SHORT).show();

      startActivity(new Intent(ListaAluno.this, Galeria.class));
    }

    if (item.getItemId() == R.principal.sincronizar) {
      Sincronismo s = new Sincronismo(ListaAluno.this);

      s.sincronizar();
    }

    if (item.getItemId() == R.principal.mapa) {
      Toast.makeText(ListaAluno.this, "Você clicou no menu \"Mapa\"", Toast.LENGTH_SHORT).show();

      startActivity(new Intent(ListaAluno.this, Mapa.class));
    }

    return super.onOptionsItemSelected(item);
  }
示例#12
0
  @Override
  public boolean onCreateOptionsMenu(android.view.Menu menu) {
    super.onCreateOptionsMenu(menu);
    try {
      if (processBA.subExists("activity_actionbarhomeclick")) {
        Class.forName("android.app.ActionBar")
            .getMethod("setHomeButtonEnabled", boolean.class)
            .invoke(getClass().getMethod("getActionBar").invoke(this), true);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (menuItems == null) return false;
    for (B4AMenuItem bmi : menuItems) {
      android.view.MenuItem mi = menu.add(bmi.title);
      if (bmi.drawable != null) mi.setIcon(bmi.drawable);
      if (android.os.Build.VERSION.SDK_INT >= 11) {
        try {
          if (bmi.addToBar) {
            android.view.MenuItem.class.getMethod("setShowAsAction", int.class).invoke(mi, 1);
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      mi.setOnMenuItemClickListener(
          new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
    }

    return true;
  }
示例#13
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   MenuItem item = menu.add(0, LICENSE, 0, "Sobre");
   item.setOnMenuItemClickListener(new MenuSobreItem());
   return true;
 }
 @Override
 public void onNavigationDrawerItemSelected(int itemId) {
   MenuItem item = mNavigationView.getMenu().findItem(itemId);
   if (item != null) {
     item.setChecked(true);
   }
 }
 private List<CharSequence> getMenuItemTitles(List<MenuItem> menuItems) {
   List<CharSequence> titles = new ArrayList<CharSequence>();
   for (MenuItem menuItem : menuItems) {
     titles.add(menuItem.getTitle());
   }
   return titles;
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    String listItemName1 = Biography[info.position - 1];
    ListView wirdlist = (ListView) findViewById(R.id.biolist);
    LayoutInflater mInflater = getLayoutInflater();
    final View mLayout =
        mInflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root));
    final TextView mText = (TextView) mLayout.findViewById(R.id.toast_text);
    Toast mToast = new Toast(getApplicationContext());
    mToast.setDuration(Toast.LENGTH_SHORT);
    mToast.setView(mLayout);

    if (item.getItemId() == 0) {

      int menuItemIndex = item.getItemId();
      String[] menuItems = getResources().getStringArray(R.array.menu2);
      String menuItemName = menuItems[menuItemIndex];

      ClipData clip = ClipData.newPlainText("simple text", listItemName1);
      clipboard.setPrimaryClip(clip);

      mText.setText("Text Copied");
      mToast.show();
    }

    return true;
  }
示例#17
0
 /*
  * (non-Javadoc)
  * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
  */
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.activity_posts, menu);
   final MenuItem newPostItem = menu.findItem(R.id.new_post);
   newPostItem.setOnMenuItemClickListener(this);
   return true;
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.first_launch, menu);
    mJobPicker = (MenuItem) menu.findItem(R.id.action_pick_job);
    mLinePicker = (MenuItem) menu.findItem(R.id.action_pick_line);
    mJobPicker.setEnabled(false);
    if (!ViewConfiguration.get(this).hasPermanentMenuKey()) {
      mJobPicker.setShowAsAction(
          MenuItem.SHOW_AS_ACTION_NEVER); // just a hack to make the arrow line up
    }

    // populate the line picker with line numbers from the database
    List<Integer> lineNumberList = new ArrayList<Integer>();
    lineNumberList = mModel.getLineNumbers();

    Menu pickLineSubMenu = mLinePicker.getSubMenu();
    pickLineSubMenu.clear();

    for (int i = 0; i < lineNumberList.size(); i++) {
      // don't have access to View.generateViewId(), so fake a random ID
      pickLineSubMenu.add(
          LINE_LIST_MENU_GROUP,
          (Menu.FIRST + lineNumberList.get(i)),
          Menu.FLAG_APPEND_TO_GROUP,
          "Line  " + String.valueOf(lineNumberList.get(i)));
    }

    return super.onCreateOptionsMenu(menu);
  }
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   String value = item.getIntent().getStringExtra(MENU_VALUE);
   switch (item.getItemId()) {
     case R.id.copy_ssid:
       {
         ClipboardManager clipboard =
             (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
         clipboard.setText(value);
         Toast.makeText(getActivity(), getString(R.string.msg_copied, value), Toast.LENGTH_SHORT)
             .show();
         return true;
       }
     case R.id.copy_mac:
       {
         ClipboardManager clipboard =
             (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
         clipboard.setText(value);
         Toast.makeText(getActivity(), getString(R.string.msg_copied, value), Toast.LENGTH_SHORT)
             .show();
         return true;
       }
     case R.id.use_mac:
       mCallbacks.onItemSelected(value);
       return true;
   }
   return super.onContextItemSelected(item);
 }
示例#20
0
  @Override
  @SuppressWarnings("unchecked")
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {
      info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
      Log.e(THIS_FILE, "bad menuInfo", e);
      return false;
    }

    HashMap<String, Object> codec = null;
    codec = (HashMap<String, Object>) mAdapter.getItem(info.position);

    if (codec == null) {
      // If for some reason the requested item isn't available, do nothing
      return false;
    }
    int selId = item.getItemId();
    if (selId == MENU_ITEM_ACTIVATE) {
      boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0);
      userActivateCodec(codec, isDisabled);
      return true;
    }
    return false;
  }
  /* Creates the menu items */
  @Override
  public boolean onCreateOptionsMenu(final Menu menu) {
    MenuItem item = menu.add(0, MENU_RETURN, 0, getString(R.string.menu_return));
    item.setIcon(android.R.drawable.ic_media_previous);

    return true;
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // évènement appelé lorsqu'un menu est choisi
   switch (item.getItemId()) {
       // l'identifiant integer est moins gourmand en ressource que le
       // string
     case 2001:
       Toast.makeText(this, "Paramètres", 1000).show();
       Intent intentParametres = new Intent(this, tab_param.class);
       intentParametres.putExtra(ActivityParam.LaunchFromRechercheProduitPerime, true);
       // on demarre la nouvelle activité
       startActivity(intentParametres);
       termineActivity();
       break;
     case 2002:
       Toast.makeText(this, "Notes", 1000).show();
       Intent intentNote = new Intent(this, note_page1.class);
       // on demarre la nouvelle activité
       startActivity(intentNote);
       termineActivity();
       break;
     case 2003:
       AlertDialog.Builder adHelp = new AlertDialog.Builder(this);
       adHelp.setTitle("Aide");
       adHelp.setIcon(R.drawable.ad_question);
       adHelp.setMessage(
           "En cliquant sur un produit vous pourrez afficher le détail de celui-ci ou le copier dans une nouvelle note.\n"
               + "En appuyant longtemps sur un produit, vous pourrez le supprimer.\n");
       adHelp.setPositiveButton("Ok", null);
       adHelp.show();
   }
   Log.i("", "" + item.getTitle());
   return super.onOptionsItemSelected(item);
 }
  // This method will trigger on item Click of navigation menu
  @Override
  public boolean onNavigationItemSelected(MenuItem menuItem) {

    // Checking if the item is in checked state or not, if not make it in checked state
    if (menuItem.isChecked()) menuItem.setChecked(false);
    else menuItem.setChecked(true);

    // Closing drawer on item click
    drawerLayout.closeDrawers();

    // Check to see which item was being clicked and perform appropriate action
    switch (menuItem.getItemId()) {
      case R.id.option_1:
        Toast.makeText(getApplicationContext(), "Option 1 Selected", Toast.LENGTH_SHORT).show();
        launchHomeFragment();
        return true;

      case R.id.option_2:
        Toast.makeText(getApplicationContext(), "Option 2 Selected", Toast.LENGTH_SHORT).show();
        return true;
      case R.id.option_3:
        Toast.makeText(getApplicationContext(), "Option 3 Selected", Toast.LENGTH_SHORT).show();
        return true;
      default:
        Toast.makeText(getApplicationContext(), "Somethings Wrong", Toast.LENGTH_SHORT).show();
        return true;
    }
  }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
   super.onCreateOptionsMenu(menu, menuInflater);
   menuInflater.inflate(R.menu.inbox_reply, menu);
   mMenuItem = menu.findItem(R.id.menu_item_inbox_reply);
   if (mMenuItem != null && mMenuItem.getActionView() != null) {
     mBtnMenuItem = (Button) mMenuItem.getActionView();
     mBtnMenuItem.setText(getString(R.string.menuitem_account_save).toUpperCase());
     mBtnMenuItem.setOnClickListener(
         new OnClickListener() {
           @Override
           public void onClick(View view) {
             PlannerEvent.getProfileUpdated().track();
             if (!isWifiConnected()) {
               showMessage(null, ERROR_DIALOG_CONTENT);
             } else if (!isSaveRequesting) {
               setInputMethodHide();
               if (PlannerApplication.isEmptyOrNull(mPhoneEditText.getText().toString())
                   || mPhoneEditText.getText().length() == 12) {
                 isSaveRequesting = true;
                 doUploadAvatar();
               } else {
                 showMessage(getString(R.string.error_phone_number));
               }
             }
           }
         });
   }
   updateMenuVisibility();
 }
  @Override
  public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    // inflater.inflate(R.menu.menu_main, menu);

    try {
      menu.add(1, 99, 1, "help")
          .setIcon(R.drawable.help_icon)
          .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

      final MenuItem action_help = menu.findItem(R.id.action_help);
      menu.findItem(R.id.action_help).setVisible(true);
      action_help.setOnMenuItemClickListener(
          new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
              menu.findItem(R.id.action_help).setVisible(false);
              return false;
            }
          });

    } catch (Exception e) {

    }
  }
示例#26
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.prefs) {
      startActivity(new Intent(this, EditPreferences.class));

      return (true);
    } else if (item.getItemId() == R.id.bff) {
      try {
        List<String> bff = new ArrayList<String>();

        for (int i = 0; i < friends.size(); i++) {
          if (friendsList.isItemChecked(i)) {
            bff.add(friends.get(i));
          }
        }

        service.setBestFriends(listener, bff);
      } catch (Throwable t) {
        Log.e("Patchy", "Exception in onOptionsItemSelected()", t);
        goBlooey(t);
      }

      return (true);
    } else if (item.getItemId() == R.id.location) {
      insertLocation();

      return (true);
    } else if (item.getItemId() == R.id.help) {
      startActivity(new Intent(this, HelpPage.class));

      return (true);
    }

    return (super.onOptionsItemSelected(item));
  }
  @Override
  public void setRefreshActionItemState(boolean refreshing) {
    // On Honeycomb, we can set the state of the refresh button by giving it a custom
    // action view.
    if (mOptionsMenu == null) {
      return;
    }

    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);
    if (refreshItem != null) {
      if (refreshing) {
        if (mRefreshIndeterminateProgressView == null) {
          LayoutInflater inflater =
              (LayoutInflater)
                  getActionBarThemedContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          mRefreshIndeterminateProgressView =
              inflater.inflate(R.layout.actionbar_indeterminate_progress, null);
        }

        refreshItem.setActionView(mRefreshIndeterminateProgressView);
      } else {
        refreshItem.setActionView(null);
      }
    }
  }
示例#28
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // book이 지정되어있지 않으면 신규 추가는 불가능 하도록 한다.
    if (mBook >= 0) {
      menu.add(0, MENU_ITEM_ADDNOTE, 0, R.string.menu_addnote)
          .setIcon(android.R.drawable.ic_menu_add);
    }
    menu.add(0, MENU_ITEM_ALLLIST, 0, R.string.menu_allnote)
        .setIcon(android.R.drawable.ic_menu_agenda);
    menu.add(0, MENU_ITEM_BOOKLIST, 0, R.string.menu_booksnote)
        .setIcon(android.R.drawable.ic_menu_agenda);

    menu.add(0, MENU_ITEM_DAYSLIST, 0, R.string.menu_daysnote)
        .setIcon(android.R.drawable.ic_menu_agenda);

    MenuItem item1 = menu.add(0, MENU_ITEM_BIBLEVIEW, 0, R.string.menu_bibleview);
    item1.setIntent(new Intent(getBaseContext(), BibleViewer.class));
    item1.setIcon(R.drawable.app_notes);
    /*
            MenuItem item2 = menu.add(0, MENU_ITEM_EDITNOTE, 0, R.string.menu_editnote);
            item2.setIntent(new Intent(getBaseContext(), NoteEditor.class));
            item2.setIcon(android.R.drawable.ic_menu_edit);

            MenuItem item3 = menu.add(0, MENU_ITEM_DELNOTE, 0, R.string.menu_deletenote);
            item3.setIntent(new Intent(getBaseContext(), NoteEditor.class));
            item3.setIcon(android.R.drawable.ic_menu_delete);
    */
    return true;
  }
示例#29
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {
      info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
      Log.e(TAG, "bad menuInfo", e);
      return false;
    }

    switch (item.getItemId()) {
      case MENU_ITEM_DELNOTE:
        {
          Log.e(TAG, "MENU_ITEM_DELFAVORITE id = " + info.id);

          dao.delete(info.id);

          loadNoteList();
          return true;
        }
      case MENU_ITEM_BIBLEVIEW:
        {
          Log.e(TAG, "MENU_ITEM_SONGVIEW uri = " + item.getIntent().getData().toString());
          startActivity(item.getIntent());
          return true;
        }
    }
    return false;
  }
 @Override
 public boolean onNavigationItemSelected(MenuItem item) {
   int id = item.getItemId();
   switch (id) {
     case R.id.nav_new:
       break;
     case R.id.nav_xingan:
       break;
     case R.id.nav_mr:
       break;
     case R.id.nav_sw:
       break;
     case R.id.nav_xz:
       break;
     case R.id.nav_wallpaper:
       break;
     case R.id.nav_share:
       break;
     case R.id.nav_personal:
       break;
   }
   toolbar.setTitle(item.getTitle());
   DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
   drawer.closeDrawer(GravityCompat.START);
   return true;
 }