List of usage examples for android.view Menu add
public MenuItem add(@StringRes int titleRes);
From source file:com.shafiq.mytwittle.view.TutorialActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); int currentItem = mViewPager.getCurrentItem(); if (currentItem != PAGE_WELCOME) { menu.add(getString(R.string.action_previous)) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*ww w . j a v a 2 s. c om*/ public boolean onMenuItemClick(MenuItem item) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1); return true; } }).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } if (currentItem != PAGE_THANKS) { menu.add(getString(R.string.action_next)) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1); return true; } }).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } return true; }
From source file:com.facebook.samples.rps.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // only add the menu when the selection fragment is showing if (fragments[RPS].isVisible()) { if (menu.size() == 0) { share = menu.add(R.string.share_on_facebook); message = menu.add(R.string.send_with_messenger); friends = menu.add(R.string.see_friends); settings = menu.add(R.string.check_settings); }/*from w w w .j a va 2s.c om*/ return true; } else { menu.clear(); settings = null; } return false; }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPFiltersFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem searchBtn = menu.findItem(R.id.action_search); searchBtn.setVisible(false);// w w w . ja v a 2s . c o m ((MainActivity) getActivity()).closeSearch(); MenuItem clearFiltersItem = menu.add(getResources().getString(R.string.btn_clear_filters)); clearFiltersItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_times) .colorRes(R.color.accentNoTransparency).actionBarSize()); clearFiltersItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); clearFiltersItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getActivity(), "Filters cleared", Toast.LENGTH_SHORT).show(); try { DBManager.setAllCategoriesSelected(false); } catch (SQLException e) { e.printStackTrace(); } ((FiltersCellAdapter) recyclerView.getAdapter()).refreshData(); synchronized (RHCareerFairLayout.refreshCompaniesNotifier) { RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged(); } getActivity().runOnUiThread(new Runnable() { @Override public void run() { recyclerView.getAdapter().notifyDataSetChanged(); } }); return true; } }); }
From source file:com.keithcassidy.finishline.LineCrossingsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem clearListMenuItem = menu.add(R.string.menu_clear_crossing_times); clearListMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); clearListMenuItem.setIcon(android.R.drawable.ic_menu_delete); clearListMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//from www. ja v a 2 s . c o m public boolean onMenuItemClick(MenuItem item) { try { deleteCrossings(); } catch (Exception e) { Log.e(TAG, "onMenuItemClick " + e); } return true; } }); MenuItem shareMenuItem = menu.add(R.string.menu_share); shareMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); shareMenuItem.setIcon(android.R.drawable.ic_menu_share); shareMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { try { sendCurrentCrossing(); } catch (Exception e) { Log.e(TAG, "onMenuItemClick " + e); } return true; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.example.android.supportv7.app.ActionBarMechanics.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Menu items default to never show in the action bar. On most devices this means // they will show in the standard options menu panel when the menu button is pressed. // On xlarge-screen devices a "More" button will appear in the far right of the // Action Bar that will display remaining items in a cascading menu. menu.add("Normal item"); MenuItem actionItem = menu.add("Action Button"); // Items that show as actions should favor the "if room" setting, which will // prevent too many buttons from crowding the bar. Extra items will show in the // overflow area. MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); // Items that show as actions are strongly encouraged to use an icon. // These icons are shown without a text description, and therefore should // be sufficiently descriptive on their own. actionItem.setIcon(android.R.drawable.ic_menu_share); return true;/*from w ww. j a va2 s. com*/ }
From source file:com.example.rps.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // only add the menu when the selection fragment is showing if (fragments[RPS].isVisible()) { if (menu.size() == 0) { share = menu.add(R.string.share_on_facebook); message = menu.add(R.string.send_with_messenger); challenge = menu.add(R.string.challenge_friends); settings = menu.add(R.string.check_settings); invite = menu.add(R.string.invite_friends); }// w ww. j ava2s . c o m return true; } else { menu.clear(); settings = null; } return false; }
From source file:com.fusionx.lightirc.ui.ChannelFragment.java
@OnClick(R.id.auto_complete_button) public void onAutoCompleteClick(final ImageButton autoComplete) { if (isPopupShown) { mPopupMenu.dismiss();//from w w w . j ava2 s . c om } else { // TODO - this needs to be synchronized properly final Collection<WorldUser> users = getChannel().getUsers(); final List<WorldUser> sortedList = new ArrayList<>(users.size()); final String message = mMessageBox.getText().toString(); final String finalWord = Iterables.getLast(IRCUtils.splitRawLine(message, false)); for (final WorldUser user : users) { if (StringUtils.startsWithIgnoreCase(user.getNick(), finalWord)) { sortedList.add(user); } } if (sortedList.size() == 1) { changeLastWord(Iterables.getLast(sortedList).getNick()); } else if (sortedList.size() > 1) { if (mPopupMenu == null) { mPopupMenu = new PopupMenu(getActivity(), autoComplete); mPopupMenu.setOnDismissListener(this); mPopupMenu.setOnMenuItemClickListener(this); } final Menu innerMenu = mPopupMenu.getMenu(); innerMenu.clear(); Collections.sort(sortedList, new IRCUserComparator(getChannel())); for (final WorldUser user : sortedList) { innerMenu.add(user.getNick()); } mPopupMenu.show(); } } }
From source file:com.rareventure.gps2.reviewer.SettingsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();//from w w w .ja va 2 s . c o m menu.add(R.string.go_to_main); return super.onPrepareOptionsMenu(menu); }
From source file:org.aakashlabs.arthashastra.Advanced_Activity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.home_, menu); // Updating score and making sure it's shown in the action bar MenuItem score_keeper = menu.add(Integer.toString(get_score())); score_keeper.setShowAsAction(2);//from w w w. jav a2 s. c o m return true; }
From source file:com.crowflying.buildwatch.ConfigurationActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Log.d(LOG_TAG, "onCreateOptionsMenu..."); super.onCreateOptionsMenu(menu); menu.add(getString(R.string.menu_request_new_token)); return true;/* w w w. j ava 2 s . co m*/ }