List of usage examples for android.view Menu add
public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);
From source file:com.scigames.registration.LoginActivity.java
/** * Called when your activity's options menu needs to be created. */// ww w . ja v a2 s . c o m @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // We are going to create two menus. Note that we assign them // unique integer IDs, labels from our string resources, and // given them shortcuts. menu.add(0, QUIT_ID, 0, R.string.quit).setShortcut('0', 'b'); menu.add(0, CLEAR_ID, 0, R.string.clear).setShortcut('1', 'c'); return true; }
From source file:net.homelinux.penecoptero.android.citybikes.app.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_ITEM_SYNC, 0, R.string.menu_sync).setIcon(R.drawable.ic_menu_refresh); menu.add(0, MENU_ITEM_LOCATION, 0, R.string.menu_location).setIcon(android.R.drawable.ic_menu_mylocation); menu.add(0, MENU_ITEM_WHATEVER, 0, R.string.menu_view_all) .setIcon(android.R.drawable.checkbox_off_background); menu.add(0, MENU_ITEM_SETTINGS, 0, R.string.menu_settings).setIcon(android.R.drawable.ic_menu_preferences); menu.add(0, MENU_ITEM_MY_ACCOUNT, 0, R.string.menu_my_account) .setIcon(android.R.drawable.ic_menu_recent_history); return true;/*from w ww . j a va2 s.c o m*/ }
From source file:gov.wa.wsdot.android.wsdot.ui.CameraImageFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem menuItem_Share = menu.findItem(R.id.action_share); shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem_Share); shareAction.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); MenuItem menuItem_Star = menu.add(0, MENU_ITEM_STAR, menu.size(), R.string.description_star); MenuItemCompat.setShowAsAction(menuItem_Star, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); if (mIsStarred) { menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star_on); } else {/*from ww w.j av a 2 s .c o m*/ menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star); } }
From source file:com.sastra.app.timetable.TimetableActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); menu.add(0, 0, 0, "Manage Subjects").setIcon(android.R.drawable.ic_menu_manage) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(1, 1, 1, "Add Class").setIcon(android.R.drawable.ic_menu_add) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(1, 2, 2, "Delete All").setIcon(android.R.drawable.ic_menu_delete) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(1, 3, 3, "About").setIcon(android.R.drawable.ic_menu_info_details) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(1, 4, 4, "Help").setIcon(android.R.drawable.ic_menu_help) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return result; }
From source file:nl.spellenclubeindhoven.dominionshuffle.SelectActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.add(Menu.NONE, MENU_SORT, Menu.NONE, R.string.menu_sort); item.setIcon(android.R.drawable.ic_menu_sort_alphabetically); item = menu.add(Menu.NONE, MENU_CLEAR_ALL, Menu.NONE, R.string.menu_clear_all); item.setIcon(R.drawable.clear_all);/* w ww. j a v a 2 s. c o m*/ item = menu.add(Menu.NONE, MENU_LOAD, Menu.NONE, R.string.menu_load); item.setIcon(android.R.drawable.ic_menu_upload); item = menu.add(Menu.NONE, MENU_SAVE, Menu.NONE, R.string.menu_save); item.setIcon(android.R.drawable.ic_menu_save); item = menu.add(Menu.NONE, MENU_SETTINGS, Menu.NONE, R.string.menu_settings); item.setIcon(R.drawable.globe); item = menu.add(Menu.NONE, MENU_LAST_RESULT, Menu.NONE, R.string.menu_last_result); item.setIcon(R.drawable.last_result); item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, R.string.menu_about); item.setIcon(android.R.drawable.stat_sys_warning); return super.onCreateOptionsMenu(menu); }
From source file:com.maxwen.wallpaper.board.activities.WallpaperBoardActivity.java
public void fileCategoryMenu(Menu menu) { List<Category> categories = new Database(this).getCategories(); for (Category c : categories) { menu.removeItem(MENU_CATEGORY_START + c.getId()); MenuItem item = menu.add(Menu.NONE, MENU_CATEGORY_START + c.getId(), Menu.NONE, c.getName()); item.setCheckable(true);//from w ww . java 2 s. co m item.setChecked(c.isSelected()); } }
From source file:com.todoroo.astrid.actfm.CommentsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (menu.size() > 0) { return;/* w ww . j a v a 2 s.c om*/ } MenuItem item; boolean showCommentsRefresh = false; if (showCommentsRefresh) { Activity activity = getActivity(); if (activity instanceof TaskListActivity) { TaskListActivity tla = (TaskListActivity) activity; showCommentsRefresh = tla.getTaskEditFragment() == null; } } if (showCommentsRefresh) { item = menu.add(Menu.NONE, MENU_REFRESH_ID, Menu.NONE, R.string.ENA_refresh_comments); item.setIcon(R.drawable.icn_menu_refresh_dark); } }
From source file:com.googlecode.CallerLookup.Main.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, MENU_CUSTOMIZE, Menu.NONE, R.string.Customize); menu.add(Menu.NONE, MENU_SAVE, Menu.NONE, R.string.Save); menu.add(Menu.NONE, MENU_REMOVE, Menu.NONE, R.string.Remove); menu.add(Menu.NONE, MENU_SUBMIT, Menu.NONE, R.string.Submit); menu.add(Menu.NONE, MENU_UPDATE, Menu.NONE, R.string.Update); menu.add(Menu.NONE, MENU_HELP, Menu.NONE, R.string.Help); return super.onCreateOptionsMenu(menu); }
From source file:com.keithandthegirl.ui.activity.GuestsDashboardFragment.java
@Override @TargetApi(11)/*from w w w . j a v a 2 s. co m*/ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { Log.v(TAG, "onCreateOptionsMenu : enter"); super.onCreateOptionsMenu(menu, inflater); MenuItem refresh = menu.add(Menu.NONE, REFRESH_ID, Menu.NONE, getResources().getString(R.string.menu_refresh)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } MenuItem mostRecent = menu.add(Menu.NONE, MOST_RECENT_ID, Menu.NONE, getResources().getString(R.string.menu_most_recent)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mostRecent.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } MenuItem topCount = menu.add(Menu.NONE, TOP_COUNT_ID, Menu.NONE, getResources().getString(R.string.menu_top_count)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { topCount.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } MenuItem name = menu.add(Menu.NONE, NAME_ID, Menu.NONE, getResources().getString(R.string.menu_name)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { name.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } Log.v(TAG, "onCreateOptionsMenu : exit"); }
From source file:com.ustadmobile.port.android.view.CatalogOPDSFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (mDeleteOptionAvailable && mSelectedEntries.length > 0) { MenuItem item = menu.add(Menu.NONE, MENUCMDID_DELETE, 1, ""); item.setIcon(R.drawable.ic_delete_white_24dp); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); }//from www.j a va2s. co m super.onCreateOptionsMenu(menu, inflater); }