List of usage examples for android.widget PopupMenu getMenu
public Menu getMenu()
From source file:org.xbmc.kore.ui.SongsListFragment.java
private void showPopupMenu(View v) { ViewHolder viewHolder = (ViewHolder) v.getTag(); final PlaylistType.Item playListItem = new PlaylistType.Item(); playListItem.songid = viewHolder.songId; final PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.musiclist_item, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//from w w w. j av a 2 s . co m public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_play: MediaPlayerUtils.play(SongsListFragment.this, playListItem); return true; case R.id.action_queue: MediaPlayerUtils.queue(SongsListFragment.this, playListItem, PlaylistType.GetPlaylistsReturnType.AUDIO); return true; } return false; } }); popupMenu.show(); }
From source file:de.spiritcroc.ownlog.ui.view.EditTagsView.java
private void showAddTagMenu() { // Ensure we have a tags provider if (mTagsProvider == null) { Log.e(TAG, "Cannot load tags: no tags provider"); return;/*from ww w . j a v a 2 s. c o m*/ } // Use context from activity instead of getContext() to separate popup from // this view's theme (padding etc.) PopupMenu popupMenu = new PopupMenu(mTagsProvider.getActivity(), mAddTagButton); Menu menu = popupMenu.getMenu(); final List<TagItem> availableTags = mTagsProvider.getAvailableTags(); final List<TagItem> setTags = mTagsProvider.getSetTags(); final HashMap<String, TagItem> tagMap = new HashMap<>(); for (TagItem tag : availableTags) { if (mAvailableTagsFilter.shouldShowTag(tag)) { menu.add(tag.name); tagMap.put(tag.name, tag); } } menu.add(R.string.edit_log_tags_add_new); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { String name = menuItem.getTitle().toString(); if (tagMap.containsKey(name)) { setTags.add(tagMap.get(name)); mTagsProvider.onSetTagsChanged(); updateContent(); } else { new TagItemEditFragment().show(mTagsProvider.getActivity().getFragmentManager(), "TagItemEditFragment"); } return false; } }); popupMenu.show(); }
From source file:com.cyanogenmod.eleven.utils.PopupMenuHelper.java
/** * Call this to inflate and show the pop up menu * @param view the view to anchor the popup menu against * @param position the item that was clicked in the popup menu (or -1 if not relevant) *///from w ww . j a va2s .c om public void showPopupMenu(final View view, final int position) { // create the popup menu PopupMenu popupMenu = new PopupMenu(mActivity, view); final Menu menu = popupMenu.getMenu(); // hook up the click listener popupMenu.setOnMenuItemClickListener(this); // figure what type of pop up menu it is mType = onPreparePopupMenu(position); if (mType != null) { // inflate the menu createPopupMenu(menu); // show it popupMenu.show(); } }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileExplorerAdapter.java
@Override protected void updateIcon(TwoLinesProgressViewHolder vh, File item) { if (item.isFile()) { Drawable drawable = getContext().getResources() .getDrawable(MimeTypeManager.getInstance(getContext()).getIcon(item.getName())); renditionManager.getPicasso().load(item).placeholder(drawable).error(drawable).into(vh.icon); AccessibilityUtils.addContentDescription(vh.icon, R.string.mime_document); } else if (item.isDirectory()) { vh.icon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.mime_folder)); AccessibilityUtils.addContentDescription(vh.icon, R.string.mime_folder); }//from w w w . j a v a 2s . c o m if (mode == FileExplorerFragment.MODE_LISTING && fragmentRef.get().getActivity() instanceof MainActivity && ((downloadPath != null && item.getPath().startsWith(downloadPath)) || (item.isFile()))) { vh.choose.setImageResource(R.drawable.ic_more_options); vh.choose.setBackgroundResource(R.drawable.alfrescohololight_list_selector_holo_light); int d_16 = DisplayUtils.getPixels(getContext(), R.dimen.d_16); vh.choose.setPadding(d_16, d_16, d_16, d_16); vh.choose.setVisibility(View.VISIBLE); AccessibilityUtils.addContentDescription(vh.choose, String.format(getContext().getString(R.string.more_options_file), item.getName())); vh.choose.setTag(R.id.node_action, item); vh.choose.setOnClickListener(new OnClickListener() { @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onClick(View v) { File item = (File) v.getTag(R.id.node_action); selectedOptionItems.add(item); PopupMenu popup = new PopupMenu(getContext(), v); getMenu(popup.getMenu(), item); popup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { selectedOptionItems.clear(); } }); popup.setOnMenuItemClickListener(FileExplorerAdapter.this); popup.show(); } }); } else { UIUtils.setBackground(vh.choose, null); vh.choose.setVisibility(View.GONE); } }
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 ww . ja va 2 s. com*/ 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:com.vrs.reqdroid.fragments.RequisitosFragment.java
/** * Mostra o PopUpMenu das opcoes do requisito. * Funciona apenas para a versao 3.0 ou superior do Android. * * @param v a view do requisito//from w ww. j a va2s . c om * */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void exibePopupMenuOpcoes(final View v) { PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.menu_opcoes_requisito, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.opcaoEditarRequisito: menuEdita(); break; case R.id.opcaoMoverRequisito: menuMove(); break; case R.id.opcaoDeletarRequisito: menuDeleta(); break; } return true; } }); popupMenu.show(); }
From source file:com.vrs.reqdroid.fragments.RequisitosAtrasadosFragment.java
/** * Mostra o PopUpMenu das opcoes do requisito. * Funciona apenas para a versao 3.0 ou superior do Android. * * @param v a view do requisito//from w ww .j a v a 2 s . c o m * */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void exibePopupMenuOpcoes(final View v) { PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.menu_opcoes_requisito_atrasado, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.opcaoEditarRequisitoAtrasado: menuEdita(); break; case R.id.opcaoMoverRequisitoAtrasado: menuMove(); break; case R.id.opcaoDeletarRequisitoAtrasado: menuDeleta(); break; } return true; } }); popupMenu.show(); }
From source file:com.vrs.reqdroid.fragments.HipotesesFragment.java
/** * Mostra o PopUpMenu das opcoes da hipotese * Funciona apenas para a versao 3.0 ou superior do Android. * * @param v a view da hipotese//from www . j a v a 2s. c o m * */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) void exibePopupMenuOpcoes(final View v) { PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.menu_opcoes_hipotese, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.opcaoEditarHipotese: menuEdita(); break; case R.id.opcaoValidarHipotese: menuValida(); break; case R.id.opcaoDeletarHipotese: menuDeleta(); break; } return true; } }); popupMenu.show(); }
From source file:de.aw.monma.mainscreen.ActivityMainScreen.java
@Override public boolean onRecyclerItemLongClick(RecyclerView recyclerView, View view, int position, long id, int viewHolderLayoutID) { switch (viewHolderLayoutID) { case R.layout.reportlist_item: PopupMenu popUpMenu = new PopupMenu(this, view); Menu menu = popUpMenu.getMenu(); popUpMenu.getMenuInflater().inflate(R.menu.context_fragment_report_selection, menu); for (int i = 0; i < menu.size(); i++) { Intent intent = new Intent(); intent.putExtra(ID, id);//from ww w . ja v a2s .com menu.getItem(i).setIntent(intent); } popUpMenu.setOnMenuItemClickListener(this); popUpMenu.show(); return true; case R.layout.finanzuebersicht_item: DialogFragmentKontoEdit d = DialogFragmentKontoEdit.newInstance(new Account((int) id)); d.show(getSupportFragmentManager(), null); return true; case R.layout.hbcipassport_item: final long mID = id; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.HBCIZugangDelete); builder.setMessage(R.string.HBCIZugangDeleteMsg); builder.setPositiveButton(getString(R.string.awlib_btnAccept), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { MonMaPassport passport = new MonMaPassport(mID); passport.delete(DBHelper.getInstance()); } catch (GeschaeftsObjekt.LineNotFoundException e) { //TODO Execption bearbeiten e.printStackTrace(); } } }); builder.setNegativeButton(getString(R.string.awlib_btnCancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); return true; default: return false; } }
From source file:com.dgsd.android.ShiftTracker.Fragment.WeekFragment.java
@Override public void onItemClick(AdapterView<?> list, final View view, int pos, long id) { final WeekAdapter.ViewHolder holder = (WeekAdapter.ViewHolder) view.getTag(); final Intent intent = getIntentFor(holder); if (!mHasTemplates || (holder != null && holder.shift != null)) { startActivity(intent);/*from w ww . j a va 2s . c o m*/ return; } final int jd = holder == null ? -1 : holder.julianDay; if (Api.isMin(Api.HONEYCOMB)) { PopupMenu popup = new PopupMenu(getActivity(), view.findViewById(R.id.text)); popup.getMenuInflater().inflate(R.menu.week_list_item_popup, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.template_shift) { showTemplateChooser(jd); } else if (item.getItemId() == R.id.new_shift) { startActivity(intent); } return false; } }); popup.show(); } else { mList.showContextMenuForChild(view); } }