List of usage examples for android.view Menu NONE
int NONE
To view the source code for android.view Menu NONE.
Click Source Link
From source file:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); if (myOptionsMenuActions.isEmpty()) { fillOptionsMenuList();/*from w ww .j a v a 2s. c o m*/ } for (Action a : myOptionsMenuActions) { final MenuItem item = menu.add(0, a.Code, Menu.NONE, ""); if (a.IconId != -1) { item.setIcon(a.IconId); } } return true; }
From source file:com.audiokernel.euphonyrmt.SearchActivity.java
@Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; switch (mPager.getCurrentItem()) { case 0:/*from w ww . j av a2 s.co m*/ final Artist artist = mArtistResults.get((int) info.id); menu.setHeaderTitle(artist.mainText()); setContextForObject(artist); break; case 1: final Album album = mAlbumResults.get((int) info.id); menu.setHeaderTitle(album.mainText()); setContextForObject(album); break; case 2: final Music music = mSongResults.get((int) info.id); final MenuItem gotoAlbumItem = menu.add(Menu.NONE, GOTO_ALBUM, 0, R.string.goToAlbum); gotoAlbumItem.setOnMenuItemClickListener(this); menu.setHeaderTitle(music.mainText()); setContextForObject(music); break; default: break; } final MenuItem addItem = menu.add(Menu.NONE, ADD, 0, getString(mAddString)); final MenuItem addAndReplaceItem = menu.add(Menu.NONE, ADD_REPLACE, 0, R.string.addAndReplace); final MenuItem addReplacePlayItem = menu.add(Menu.NONE, ADD_REPLACE_PLAY, 0, R.string.addAndReplacePlay); final MenuItem addAndPlayItem = menu.add(Menu.NONE, ADD_PLAY, 0, R.string.addAndPlay); addItem.setOnMenuItemClickListener(this); addAndReplaceItem.setOnMenuItemClickListener(this); addReplacePlayItem.setOnMenuItemClickListener(this); addAndPlayItem.setOnMenuItemClickListener(this); }
From source file:pro.dbro.iburn_2012.OpenStreetMapFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (!FragmentTabsPager.app.embargoClear) { MenuItem unlockItem = menu.add(Menu.NONE, R.id.menu_unlock, Menu.NONE, "Unlock"); MenuItemCompat.setShowAsAction(unlockItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); unlockItem.setIcon(R.drawable.unlock); unlockItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//from w ww.j a va2s .c o m public boolean onMenuItemClick(MenuItem item) { if (!FragmentTabsPager.app.embargoClear) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Enter Unlock Password"); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (value.compareTo(FragmentTabsPager.app.unlockPassword) == 0) { FragmentTabsPager.app.setEmbargoClear(true); mLocationOverlay.enableMyLocation(); getActivity().findViewById(R.id.map_placeholder).setVisibility(View.GONE); mapView.setVisibility(View.VISIBLE); } else { dialog.cancel(); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Invalid Password"); alert.show(); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); //FragmentTabsPager.app.embargoClear = true; } return false; } }); } }
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.mifos.mifosxdroid.online.SavingsAccountSummaryFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear();//w w w. ja va 2s .c om menu.addSubMenu(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_SAVINGS_ACCOUNTS_NAME); menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents)); // This is the ID of Each data table which will be used in onOptionsItemSelected Method int SUBMENU_ITEM_ID = 0; // Create a Sub Menu that holds a link to all data tables SubMenu dataTableSubMenu = menu.getItem(1).getSubMenu(); if (dataTableSubMenu != null && savingsAccountDataTables != null && savingsAccountDataTables.size() > 0) { Iterator<DataTable> dataTableIterator = savingsAccountDataTables.iterator(); while (dataTableIterator.hasNext()) { dataTableSubMenu.add(Menu.NONE, SUBMENU_ITEM_ID, Menu.NONE, dataTableIterator.next().getRegisteredTableName()); SUBMENU_ITEM_ID++; } } super.onPrepareOptionsMenu(menu); }
From source file:com.ushahidi.android.presentation.view.ui.activity.PostActivity.java
private void setNavigationViewMenuItems(@NonNull Menu menu) { // Reset menu items to avoid duplicates because we reinitialize them menu.clear();/*from w w w . j a va 2 s .c o m*/ if (!Utility.isCollectionEmpty(mDeploymentModelList)) { SubMenu subMenu = menu.addSubMenu(Menu.NONE, Menu.FIRST, Menu.NONE, R.string.deployments); subMenu.setGroupCheckable(DEPLOYMENTS_MENU_ITEMS_GROUP_ID, true, true); // Use item position as the menu item's id that way we can retrieve the individual // deployment when user clicks on it to make it the active deployment for (int pos = 0; pos < mDeploymentModelList.size(); pos++) { subMenu.add(DEPLOYMENTS_MENU_ITEMS_GROUP_ID, pos, pos, mDeploymentModelList.get(pos).getTitle()) .setIcon(R.drawable.ic_action_globe); if (mDeploymentModelList.get(pos).getStatus().equals(DeploymentModel.Status.ACTIVATED)) { mNavigationView.getMenu().findItem(pos).setChecked(true); mToolbar.setTitle(mNavigationView.getMenu().findItem(pos).getTitle()); } else { mNavigationView.getMenu().findItem(pos).setChecked(false); } } } mSubMenuMisc = menu.addSubMenu(Menu.NONE, Menu.FIRST, Menu.NONE, R.string.actions); mSubMenuMisc.add(MISC_MENU_ITEMS, MANAGE_DEPLOYMENT_MENU_ID, 1, R.string.manage_deployments) .setIcon(R.drawable.ic_action_map); mSubMenuMisc.add(MISC_MENU_ITEMS, FEEDBACK_MENU_ID, 2, R.string.send_feedback) .setIcon(R.drawable.ic_action_help); mSubMenuMisc.add(MISC_MENU_ITEMS, ABOUT_MENU_ID, 3, R.string.about).setIcon(R.drawable.ic_action_info); if (mSessionManager.getActiveSession() != null) { mSubMenuMisc.add(MISC_MENU_ITEMS, LOGOUT_MENU_ID, 4, R.string.logout) .setIcon(R.drawable.ic_action_logout); } mSubMenuMisc.setGroupCheckable(MISC_MENU_ITEMS, true, true); }
From source file:com.grarak.kerneladiutor.fragments.tools.customcontrols.CustomControlsFragment.java
private CardView getCard(final Controls.ControlItem controlItem) { CardView cardView = new CardView(getActivity()); cardView.setOnMenuListener(new CardView.OnMenuListener() { @Override//from ww w .j a v a2s.co m public void onMenuReady(CardView cardView, PopupMenu popupMenu) { Menu menu = popupMenu.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, getString(R.string.edit)); final MenuItem onBoot = menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.on_boot)) .setCheckable(true); onBoot.setChecked(controlItem.isOnBootEnabled()); menu.add(Menu.NONE, 2, Menu.NONE, getString(R.string.export)); menu.add(Menu.NONE, 3, Menu.NONE, getString(R.string.delete)); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case 0: edit(controlItem); break; case 1: onBoot.setChecked(!onBoot.isChecked()); controlItem.enableOnBoot(onBoot.isChecked()); mControlsProvider.commit(); break; case 2: mExportItem = controlItem; requestPermission(0, Manifest.permission.WRITE_EXTERNAL_STORAGE); break; case 3: mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { delete(controlItem.getUniqueId()); } }, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { mDeleteDialog = null; } }, getActivity()).setTitle(getString(R.string.delete)); mDeleteDialog.show(); break; } return false; } }); } }); return cardView; }
From source file:org.apache.cordova.plugins.Actionable.java
public void buildMenu() { for (Actionable act : mMenuItems.values()) { MenuItem mi = mMenu.add(Menu.NONE, Menu.NONE, act.getOrder(), act.getTitle()); mi.setTitleCondensed(act.getTitle()); mi.setShowAsAction(act.getFlags()); if (act.isDisabled()) { mi.setEnabled(false);/*from w ww .ja v a 2 s . c o m*/ } if (act.getIcon() != null) { mi.setIcon(act.getIcon()); } } }
From source file:org.catnut.plugin.zhihu.ZhihuItemFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(Menu.NONE, ACTION_VIEW_ALL_ON_WEB, Menu.NONE, getString(R.string.view_all_answer)); menu.add(Menu.NONE, ACTION_VIEW_ON_WEB, Menu.NONE, getString(R.string.zhihu_view_on_web)); super.onCreateContextMenu(menu, v, menuInfo); }
From source file:de.gebatzens.sia.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(SIAApp.SIA_APP.school.getTheme()); super.onCreate(savedInstanceState); Log.w("ggvp", "CREATE NEW MAINACTIVITY"); //Debug.startMethodTracing("sia3"); SIAApp.SIA_APP.activity = this; savedState = savedInstanceState;/*from w w w . j av a2s. c o m*/ final FragmentData.FragmentList fragments = SIAApp.SIA_APP.school.fragments; Intent intent = getIntent(); if (intent != null && intent.getStringExtra("fragment") != null) { FragmentData frag = fragments .getByType(FragmentData.FragmentType.valueOf(intent.getStringExtra("fragment"))).get(0); SIAApp.SIA_APP.setFragmentIndex(fragments.indexOf(frag)); } if (intent != null && intent.getBooleanExtra("reload", false)) { SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); intent.removeExtra("reload"); } setContentView(R.layout.activity_main); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); mContent = getFragment(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); Log.d("ggvp", "DATA: " + fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData()); if (fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); if ("Summer".equals(SIAApp.SIA_APP.getCurrentThemeName())) { ImageView summerNavigationPalm = (ImageView) findViewById(R.id.summer_navigation_palm); summerNavigationPalm.setImageResource(R.drawable.summer_palm); ImageView summerBackgroundImage = (ImageView) findViewById(R.id.summer_background_image); summerBackgroundImage.setImageResource(R.drawable.summer_background); } mToolBar = (Toolbar) findViewById(R.id.toolbar); mToolBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_refresh: ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true); SIAApp.SIA_APP.refreshAsync(new Runnable() { @Override public void run() { ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)) .setRefreshing(false); } }, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); return true; case R.id.action_settings: Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); return true; case R.id.action_addToCalendar: showExamDialog(); return true; case R.id.action_help: AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(getApplication().getString(R.string.help)); builder.setMessage(getApplication().getString(R.string.exam_explain)); builder.setPositiveButton(getApplication().getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); return true; } return false; } }); updateToolbar(SIAApp.SIA_APP.school.name, fragments.get(SIAApp.SIA_APP.getFragmentIndex()).name); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SIAApp.SIA_APP.setStatusBarColorTransparent(getWindow()); // because of the navigation drawer } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.addDrawerListener(mDrawerToggle); navigationView = (NavigationView) findViewById(R.id.navigation_view); mNavigationHeader = navigationView.getHeaderView(0); mNavigationSchoolpictureText = (TextView) mNavigationHeader.findViewById(R.id.drawer_image_text); mNavigationSchoolpictureText.setText(SIAApp.SIA_APP.school.name); mNavigationSchoolpicture = (ImageView) mNavigationHeader.findViewById(R.id.navigation_schoolpicture); mNavigationSchoolpicture.setImageBitmap(SIAApp.SIA_APP.school.loadImage()); mNavigationSchoolpictureLink = mNavigationHeader.findViewById(R.id.navigation_schoolpicture_link); mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent linkIntent = new Intent(Intent.ACTION_VIEW); linkIntent.setData(Uri.parse(SIAApp.SIA_APP.school.website)); startActivity(linkIntent); } }); final Menu menu = navigationView.getMenu(); menu.clear(); for (int i = 0; i < fragments.size(); i++) { MenuItem item = menu.add(R.id.fragments, Menu.NONE, i, fragments.get(i).name); item.setIcon(fragments.get(i).getIconRes()); } menu.add(R.id.settings, R.id.settings_item, fragments.size(), R.string.settings); menu.setGroupCheckable(R.id.fragments, true, true); menu.setGroupCheckable(R.id.settings, false, false); final Menu navMenu = navigationView.getMenu(); selectedItem = SIAApp.SIA_APP.getFragmentIndex(); if (selectedItem != -1) navMenu.getItem(selectedItem).setChecked(true); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.settings_item) { mDrawerLayout.closeDrawers(); Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } else { final int index = menuItem.getOrder(); if (SIAApp.SIA_APP.getFragmentIndex() != index) { SIAApp.SIA_APP.setFragmentIndex(index); menuItem.setChecked(true); updateToolbar(SIAApp.SIA_APP.school.name, menuItem.getTitle().toString()); mContent = getFragment(); Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.setVisibility(View.INVISIBLE); if (fragments.get(index).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(index)); //removeAllFragments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); snowView.updateSnow(); } @Override public void onAnimationRepeat(Animation animation) { } }); FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.startAnimation(fadeOut); mDrawerLayout.closeDrawers(); } else { mDrawerLayout.closeDrawers(); } } return true; } }); if (Build.VERSION.SDK_INT >= 25) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); shortcutManager.removeAllDynamicShortcuts(); for (int i = 0; i < fragments.size(); i++) { Drawable drawable = getDrawable(fragments.get(i).getIconRes()); Bitmap icon; if (drawable instanceof VectorDrawable) { icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(icon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } else { icon = BitmapFactory.decodeResource(getResources(), fragments.get(i).getIconRes()); } Bitmap connectedIcon = Bitmap.createBitmap(icon.getWidth(), icon.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(connectedIcon); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.parseColor("#f5f5f5")); canvas.drawCircle(icon.getWidth() / 2, icon.getHeight() / 2, icon.getWidth() / 2, paint); paint.setColorFilter( new PorterDuffColorFilter(SIAApp.SIA_APP.school.getColor(), PorterDuff.Mode.SRC_ATOP)); canvas.drawBitmap(icon, null, new RectF(icon.getHeight() / 4.0f, icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f), paint); Intent newTaskIntent = new Intent(this, MainActivity.class); newTaskIntent.setAction(Intent.ACTION_MAIN); newTaskIntent.putExtra("fragment", fragments.get(i).type.toString()); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, fragments.get(i).name) .setShortLabel(fragments.get(i).name).setLongLabel(fragments.get(i).name) .setIcon(Icon.createWithBitmap(connectedIcon)).setIntent(newTaskIntent).build(); shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut)); } } if (SIAApp.SIA_APP.preferences.getBoolean("app_130_upgrade", true)) { if (!SIAApp.SIA_APP.preferences.getBoolean("first_use_filter", true)) { TextDialog.newInstance(R.string.upgrade1_3title, R.string.upgrade1_3) .show(getSupportFragmentManager(), "upgrade_dialog"); } SIAApp.SIA_APP.preferences.edit().putBoolean("app_130_upgrade", false).apply(); } snowView = (SnowView) findViewById(R.id.snow_view); shareToolbar = (Toolbar) findViewById(R.id.share_toolbar); shareToolbar.getMenu().clear(); shareToolbar.inflateMenu(R.menu.share_toolbar_menu); shareToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleShareToolbar(false); for (Shareable s : MainActivity.this.shared) { s.setMarked(false); } MainActivity.this.shared.clear(); mContent.updateFragment(); } }); shareToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { toggleShareToolbar(false); HashMap<Date, ArrayList<Shareable>> dates = new HashMap<Date, ArrayList<Shareable>>(); for (Shareable s : MainActivity.this.shared) { ArrayList<Shareable> list = dates.get(s.getDate()); if (list == null) { list = new ArrayList<Shareable>(); dates.put(s.getDate(), list); } list.add(s); s.setMarked(false); } MainActivity.this.shared.clear(); List<Date> dateList = new ArrayList<Date>(dates.keySet()); Collections.sort(dateList); String content = ""; for (Date key : dateList) { content += SubstListAdapter.translateDay(key) + "\n\n"; Collections.sort(dates.get(key)); for (Shareable s : dates.get(key)) { content += s.getShareContent() + "\n"; } content += "\n"; } content = content.substring(0, content.length() - 1); mContent.updateFragment(); if (item.getItemId() == R.id.action_copy) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(getString(R.string.entries), content); clipboard.setPrimaryClip(clip); } else if (item.getItemId() == R.id.action_share) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, content); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to))); } return true; } }); if (shared.size() > 0) { shareToolbar.setVisibility(View.VISIBLE); updateShareToolbarText(); } // if a fragment is opened via a notification or a shortcut reset the shared entries // delete extra fragment because the same intent is used when the device gets rotated and the user could have opened a new fragment if (intent != null && intent.hasExtra("fragment")) { resetShareToolbar(); intent.removeExtra("fragment"); } }