List of usage examples for android.widget PopupMenu PopupMenu
public PopupMenu(Context context, View anchor)
From source file:com.filepager.afilechooser.FileChooserActivity.java
public void showPopUp(View v) { PopupMenu popup = new PopupMenu(this, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.file_type_selection, popup.getMenu()); popup.show();/* w w w .jav a 2 s .co m*/ }
From source file:com.tlongdev.bktf.ui.fragment.FavoritesFragment.java
@Override public void onMoreClicked(View view, final Item item) { PopupMenu menu = new PopupMenu(getActivity(), view); menu.getMenuInflater().inflate(R.menu.popup_item, menu.getMenu()); menu.getMenu().findItem(R.id.favorite).setTitle("Remove from favorites"); menu.getMenu().findItem(R.id.calculator).setEnabled(!Utility.isInCalculator(getActivity(), item)); menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override// www . j a v a2s . co m public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.history: Intent i = new Intent(getActivity(), PriceHistoryActivity.class); i.putExtra(PriceHistoryActivity.EXTRA_ITEM, item); startActivity(i); break; case R.id.favorite: Utility.removeFromFavorites(getActivity(), item); mAdapter.removeItem(item); break; case R.id.calculator: Utility.addToCalculator(getActivity(), item); menuItem.setEnabled(false); break; case R.id.backpack_tf: CustomTabActivityHelper.openCustomTab(getActivity(), new CustomTabsIntent.Builder().build(), Uri.parse(item.getBackpackTfUrl()), new WebViewFallback()); break; case R.id.wiki: CustomTabActivityHelper.openCustomTab(getActivity(), new CustomTabsIntent.Builder().build(), Uri.parse(item.getTf2WikiUrl()), new WebViewFallback()); break; } return true; } }); menu.show(); }
From source file:com.pdftron.pdf.controls.UserBookmarkDialogFragment.java
public void onShowPopupMenu(final int position, View anchor) { PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); Menu menu = popupMenu.getMenu(); final UserBookmarkItem bItem = mBookmarkViewAdapter.getItem(position); String[] menuItems = getResources().getStringArray(R.array.user_bookmark_dialog_context_menu); menu.add(Menu.NONE, CONTEXT_MENU_EDIT_ITEM, CONTEXT_MENU_EDIT_ITEM, menuItems[CONTEXT_MENU_EDIT_ITEM]); menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ITEM, CONTEXT_MENU_DELETE_ITEM, menuItems[CONTEXT_MENU_DELETE_ITEM]); menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ALL, CONTEXT_MENU_DELETE_ALL, menuItems[CONTEXT_MENU_DELETE_ALL]); MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() { @Override/*from w w w.ja v a 2 s . com*/ public boolean onMenuItemClick(MenuItem item) { onPopupItemSelected(item, position); return true; } }; menu.getItem(CONTEXT_MENU_EDIT_ITEM).setOnMenuItemClickListener(listener); menu.getItem(CONTEXT_MENU_DELETE_ITEM).setOnMenuItemClickListener(listener); menu.getItem(CONTEXT_MENU_DELETE_ALL).setOnMenuItemClickListener(listener); popupMenu.show(); }
From source file:com.owncloud.android.ui.adapter.UserListAdapter.java
private void onOverflowIconClicked(View view, AppCompatCheckBox allowEditsCheckBox, OCShare share) { // use grey as fallback for elements where custom theming is not available if (ThemeUtils.themingEnabled(context)) { context.getTheme().applyStyle(R.style.FallbackThemingTheme, true); }//from w ww .j a v a 2 s . c o m PopupMenu popup = new PopupMenu(context, view); popup.inflate(R.menu.file_detail_sharing_menu); prepareOptionsMenu(popup.getMenu(), share); popup.setOnMenuItemClickListener( item -> optionsItemSelected(popup.getMenu(), item, allowEditsCheckBox, share)); popup.show(); }
From source file:com.jrummyapps.busybox.fragments.ScriptsFragment.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final ShellScript script = adapter.getItem(position); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // hack to get the popupmenu color working on Android 6.0+ for custom color schemes ContextCompat.getDrawable(getActivity(), R.drawable.bg_popup_dark); ContextCompat.getDrawable(getActivity(), R.drawable.bg_popup_light); }//from w w w . j ava 2 s . c o m PopupMenu popupMenu = new PopupMenu(getActivity(), view); popupMenu.getMenu().add(0, 1, 0, R.string.run).setIcon(R.drawable.ic_play_white_24dp); popupMenu.getMenu().add(0, 2, 0, R.string.edit).setIcon(R.drawable.ic_edit_white_24dp); popupMenu.getMenu().add(0, 3, 0, R.string.info).setIcon(R.drawable.ic_information_white_24dp); popupMenu.getMenu().add(0, 4, 0, R.string.delete).setIcon(R.drawable.ic_delete_white_24dp); getRadiant().tint(popupMenu.getMenu()).forceIcons().apply(getActivity()); Analytics.newEvent("clicked script").put("script_name", script.name).put("script_file", script.path).log(); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case 1: { // run Intent intent = new Intent(getActivity(), ScriptExecutorActivity.class); intent.putExtra(FileIntents.INTENT_EXTRA_PATH, script.path); startActivity(intent); return true; } case 2: { // edit Intent intent = new Intent(getActivity(), TextEditorActivity.class); intent.putExtra(FileIntents.INTENT_EXTRA_PATH, script.path); startActivity(intent); return true; } case 3: { // info Intent intent = new Intent(getActivity(), FilePropertiesActivity.class); intent.putExtra(FileIntents.INTENT_EXTRA_FILE, new File(script.path)); intent.putExtra(FilePropertiesActivity.EXTRA_DESCRIPTION, script.info); startActivity(intent); return true; } case 4: { // delete ShellScriptTable table = Database.getInstance().getTable(ShellScriptTable.NAME); boolean deleted = table.delete(script) != 0; if (deleted) { adapter.scripts.remove(script); adapter.notifyDataSetChanged(); new File(script.path).delete(); } return true; } default: return false; } } }); popupMenu.show(); }
From source file:org.hawkular.client.android.fragment.AlertDetailFragment.java
private void showAlertMenu(final View view) { PopupMenu alertMenu = new PopupMenu(getActivity(), view); alertMenu.getMenuInflater().inflate(R.menu.popup_alerts, alertMenu.getMenu()); alertMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/*from w ww . j a va 2 s .com*/ public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_resolve: BackendClient.of(AlertDetailFragment.this).resolveAlert(alert, new AlertActionCallback(R.string.alert_state_res)); return true; case R.id.menu_acknowledge: BackendClient.of(AlertDetailFragment.this).acknowledgeAlert(alert, new AlertActionCallback(R.string.alert_state_ack)); return true; default: return false; } } }); alertMenu.show(); }
From source file:de.schildbach.wallet.ui.monitor.BlockListFragment.java
@Override public void onBlockMenuClick(final View view, final Sha256Hash blockHash) { final PopupMenu popupMenu = new PopupMenu(activity, view); popupMenu.inflate(R.menu.blocks_context); popupMenu.getMenu().findItem(R.id.blocks_context_browse).setVisible(Constants.ENABLE_BROWSE); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//ww w .j a v a2s . c o m public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.blocks_context_browse: final Uri blockExplorerUri = config.getBlockExplorer(); log.info("Viewing block {} on {}", blockHash, blockExplorerUri); startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(blockExplorerUri, "block/" + blockHash))); return true; } return false; } }); popupMenu.show(); }
From source file:de.aw.monma.wertpapier.FragmentWertpapierBuchungenListe.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.awlib_defaultFAB: PopupMenu popUpMenu = new PopupMenu(getActivity(), v); Menu menu = popUpMenu.getMenu(); // Aufbau des zugehoerigen Submenues for (WPUmsatzArt umsatzArt : WPUmsatzArt.values()) { switch (umsatzArt) { case Kauf: case OthrInc: case WP_Einlage: case Ausgabe: Intent intent = new Intent(getActivity(), ActivityWPUmsatz.class); intent.putExtra(ACTION, (Parcelable) Action.DoWertpapierUmsatz); intent.putExtra(ACCOUNTID, mAccountID); intent.putExtra(WPUMSATZART, umsatzArt); MenuItem item = menu.add(Menu.NONE, umsatzArt.getTextResID(), Menu.NONE, umsatzArt.getBeschreibungID()); item.setIntent(intent);/*from www .ja v a 2 s. co m*/ } } popUpMenu.show(); break; default: } }
From source file:com.android.calculator3.Calculator2.java
private PopupMenu constructPopupMenu() { final PopupMenu popupMenu = new PopupMenu(this, mOverflowMenuButton); mOverflowMenuButton.setOnTouchListener(popupMenu.getDragToOpenListener()); final Menu menu = popupMenu.getMenu(); popupMenu.inflate(R.menu.menu);//w w w . j a va 2s .c o m popupMenu.setOnMenuItemClickListener(this); onPrepareOptionsMenu(menu); return popupMenu; }
From source file:com.lovejoy777sarootool.rootool.fragments.BrowserFragment.java
private void showMenu(View v) { PopupMenu popup = new PopupMenu(mActivity, v); // This activity implements OnMenuItemClickListener popup.setOnMenuItemClickListener(this); popup.inflate(R.menu.fab_menu);/*from w w w .jav a 2s.com*/ popup.show(); }