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.wheelly.fragments.LocationsMapFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); BusProvider.getInstance().register(this); inSelectMode = getActivity().getIntent().hasExtra(LocationActivity.LOCATION_ID_EXTRA); // Getting Google Play availability status int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()); // Showing status if (status != ConnectionResult.SUCCESS) { // Google Play Services are not available int requestCode = 10; Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, getActivity(), requestCode); dialog.show();//from ww w. j a v a 2 s. com } else { // Google Play Services are available // Getting GoogleMap object from the fragment googleMap = getMap(); } ApiAdapterFactory.getApiAdapter().configureMapViewContextualMenu(this, new MapContextActionCallback() { private EditText editText; @Override public void onPrepare(Menu menu, Marker marker) { configureTitleWidget(marker); } @SuppressLint("NewApi") @Override public void onCreate(Menu menu) { editText = (EditText) menu.add(0, 0, 0, "name").setIcon(android.R.drawable.ic_menu_edit) .setActionView(R.layout.location_edit).getActionView().findViewById(R.id.location_name); menu.add(0, 1, 0, R.string.item_add).setIcon(android.R.drawable.ic_menu_save); } private void configureTitleWidget(Marker marker) { if (null != marker && null != editText) { try { final long id = Long.parseLong(marker.getSnippet()); editText.setText(new LocationBroker(getActivity()).loadOrCreate(id).getAsString("name")); } catch (NumberFormatException nfex) { LocationUtils.resolveAddress(getActivity(), marker.getPosition(), "", new AddressResolveCallback() { @Override public void onResolved(Address address) { if (getResources().getString(R.string.new_location) .equals(editText.getText().toString()) && null != address) { editText.setText(LocationUtils.formatAddress(address)); } } }); } } } @Override public boolean onClick(MenuItem item, Marker marker) { if (null != marker) { final ContentValues myLocation = new ContentValues(); try { final long id = Long.parseLong(marker.getSnippet()); myLocation.put(BaseColumns._ID, id); } catch (NumberFormatException nfex) { myLocation.put("provider", "fusion"); } if (null != editText) { myLocation.put("name", editText.getText().toString()); } myLocation.put("latitude", marker.getPosition().latitude); myLocation.put("longitude", marker.getPosition().longitude); myLocation.put("datetime", System.currentTimeMillis()); LocationUtils.resolveAddress(getActivity(), marker.getPosition(), myLocation.getAsString("name"), new AddressResolveCallback() { @Override public void onResolved(Address address) { if (null != address) { myLocation.put("resolved_address", LocationUtils.formatAddress(address)); } new LocationBroker(getActivity()).updateOrInsert(myLocation); } }); return true; } return false; } }); }
From source file:fr.pasteque.client.Configure.java
@Override public boolean onCreateOptionsMenu(Menu menu) { int i = 0;/*from www . j ava 2s.c o m*/ MenuItem imp = menu.add(Menu.NONE, MENU_IMPORT_ID, i++, this.getString(R.string.menu_cfg_import)); imp.setIcon(android.R.drawable.ic_menu_revert); MenuItem exp = menu.add(Menu.NONE, MENU_EXPORT_ID, i++, this.getString(R.string.menu_cfg_export)); exp.setIcon(android.R.drawable.ic_menu_edit); MenuItem dbg = menu.add(Menu.NONE, MENU_DEBUG_ID, i, this.getString(R.string.menu_cfg_debug)); dbg.setIcon(android.R.drawable.ic_menu_report_image); return true; }
From source file:org.alfresco.mobile.android.application.fragments.node.browser.ProgressNodeAdapter.java
public void getMenu(Menu menu, Node node) { MenuItem mi;/* www . j a v a 2 s . co m*/ mi = menu.add(Menu.NONE, R.id.menu_node_details, Menu.FIRST, R.string.action_view_properties); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (ConfigurableActionHelper.isVisible(getActivity(), SessionUtils.getAccount(getActivity()), SessionUtils.getSession(getActivity()), node, ConfigurableActionHelper.ACTION_NODE_EDIT)) { mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 50, R.string.action_edit_properties); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } if (ConfigurableActionHelper.isVisible(getActivity(), SessionUtils.getAccount(getActivity()), SessionUtils.getSession(getActivity()), node, ConfigurableActionHelper.ACTION_NODE_DELETE)) { mi = menu.add(Menu.NONE, R.id.menu_action_delete_folder, Menu.FIRST + 1000, R.string.delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } }
From source file:com.appfirst.activities.details.AFServerDetail.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, 1, 0, "CPU cores").setIcon(R.drawable.ic_menu_cpu); menu.add(0, 1, 0, "Disk usage").setIcon(R.drawable.ic_menu_disk); menu.add(0, 1, 0, "Disk busy").setIcon(R.drawable.ic_menu_diskbusy); return super.onCreateOptionsMenu(menu); }
From source file:edu.cmu.cylab.starslinger.view.SaveActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.add(0, MENU_HELP, 0, R.string.menu_Help).setIcon(R.drawable.ic_action_help); MenuCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); menu.add(0, MENU_FEEDBACK, 0, R.string.menu_sendFeedback).setIcon(android.R.drawable.ic_menu_send); return true;/*www.j a v a 2s . c om*/ }
From source file:com.esri.android.mapsapp.tools.MeasuringTool.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { mMode = mode;/*from w ww . j a v a2 s .com*/ init(); MenuItem item; item = menu.add(Menu.NONE, MENU_UNDO, 1, "undo"); item.setIcon(android.R.drawable.ic_menu_revert); item.setVisible(false); item = menu.add(Menu.NONE, MENU_DELETE, 2, "clear"); item.setIcon(android.R.drawable.ic_menu_delete); item.setVisible(false); item = menu.add(Menu.NONE, MENU_PREF, 3, "preferences"); item.setIcon(android.R.drawable.ic_menu_manage); item.setActionProvider(new Preferences(mContext)); return true; }
From source file:com.glabs.homegenie.fragments.GroupsViewFragment.java
public void UpdateJumpToGroupMenu(ArrayList<Group> groups) { StartActivity rootactivity = (StartActivity) getActivity(); if (rootactivity != null) { Menu menu = rootactivity.getActionMenu(); if (menu != null) { MenuItem jumpto = menu.findItem(R.id.action_jumpto); Menu submenu = jumpto.getSubMenu(); if (submenu == null) return; ///* w w w. ja v a 2 s. c o m*/ submenu.removeGroup(Menu.NONE); if (groups.size() > 0) { int gid = 0; for (Group group : groups) { MenuItem grp = submenu.add(Menu.NONE, gid, gid, group.Name); // prg.setIcon(R.drawable.ic_action_flash_on); MenuCompat.setShowAsAction(grp, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT); grp.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { mIndicator.setCurrentItem(menuItem.getItemId()); return true; } }); gid++; } } } } }
From source file:de.kaidev.vertretungsplanapp.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem info = menu.add(0, 99, 0, "Info").setIcon(R.drawable.ic_info_outline_white_48dp); info.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); int i = mPager != null ? mPager.getCurrentItem() : 0; String s = i == 0 ? heute.getInfo() : morgen.getInfo(); if (!s.isEmpty()) { for (String t : s.split("\n")) { if (!t.startsWith("Abwesende") && !t.startsWith("Blockierte")) { info.setIcon(R.drawable.ic_info_white_48dp); break; }//w w w .j a v a 2s. co m } } return super.onCreateOptionsMenu(menu); }
From source file:io.mpos.ui.shared.view.SummaryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (showSendReceiptButton()) { menu.add(Menu.NONE, R.id.mpu_send_receipt_action_id, Menu.NONE, R.string.MPUSend) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); }//w w w.j a v a 2 s. c om super.onCreateOptionsMenu(menu, inflater); }