List of usage examples for android.widget PopupMenu show
public void show()
From source file:org.videolan.vlc.gui.video.VideoGridFragment.java
@TargetApi(11) public void onContextPopupMenu(View anchor, final int position) { if (!Util.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick();//from w w w.ja v a 2s . com return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
From source file:app.umitems.greenclock.DeskClockFragment.java
/** * Installs click and touch listeners on a fake overflow menu button. * * @param menuButton the fragment's fake overflow menu button *///from ww w . ja v a 2 s . com public void setupFakeOverflowMenuButton(View menuButton) { final PopupMenu fakeOverflow = new PopupMenu(menuButton.getContext(), menuButton) { @Override public void show() { getActivity().onPrepareOptionsMenu(getMenu()); super.show(); } }; fakeOverflow.inflate(R.menu.desk_clock_menu); fakeOverflow.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return getActivity().onOptionsItemSelected(item); } }); menuButton.setOnTouchListener(PopupMenuCompat.getDragToOpenListener(fakeOverflow)); menuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fakeOverflow.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 w w w .j av a 2 s. c om*/ 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:org.akop.crosswords.fragment.CrosswordFragment.java
@Override public void onCellLongPressed(CrosswordView view, Crossword.Word word, int cell) { // Get the highlighted cell's rectangle Rect rect = view.getCellRect(word, cell); // Offset the placeholder to the same position as the cell FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(rect.width(), rect.height()); lp.setMargins(rect.left, rect.top, 0, 0); mMenuPlaceholder.setLayoutParams(lp); // Save the word/cell associated with the popup mPopupWord = word;//from w w w.java 2s. c om mPopupCell = cell; // Initialize and show the popup menu PopupMenu popup = new PopupMenu(getActivity(), mMenuPlaceholder); popup.setOnMenuItemClickListener(mCellPopupListener); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.fragment_crossword_popup_cell, popup.getMenu()); popup.show(); }
From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java
public void showTextPopup(View v) { PopupMenu popup = new PopupMenu(this, v); configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT); popup.show(); }
From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java
public void showVideoPopup(View v) { PopupMenu popup = new PopupMenu(this, v); configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO); popup.show(); }
From source file:com.fastbootmobile.encore.app.adapters.SearchAdapter.java
private void showArtistOverflow(final Context context, View parent, final Artist artist) { PopupMenu popupMenu = new PopupMenu(context, parent); popupMenu.inflate(R.menu.search_res_artist); popupMenu.show(); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//from w ww .j ava 2 s . c o m public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_play_now: List<Song> radio = Suggestor.getInstance().buildArtistRadio(artist); PlaybackProxy.clearQueue(); for (Song song : radio) { PlaybackProxy.queueSong(song, false); } PlaybackProxy.playAtIndex(0); break; default: return false; } return true; } }); }
From source file:org.alfresco.mobile.android.application.fragments.sync.SyncCursorAdapter.java
protected void updateBottomText(TwoLinesProgressViewHolder vh, final Cursor cursor) { int status = cursor.getInt(SyncContentSchema.COLUMN_STATUS_ID); String nodeId = cursor.getString(SyncContentSchema.COLUMN_NODE_ID_ID); long favoriteId = cursor.getLong(SyncContentSchema.COLUMN_ID_ID); boolean syncRoot = cursor.getInt(SyncContentSchema.COLUMN_IS_SYNC_ROOT_ID) > 0; if (syncRoot) { vh.favoriteIcon.setVisibility(View.VISIBLE); vh.favoriteIcon.setImageResource(R.drawable.ic_sync_light); } else {/* w w w .ja v a2 s. com*/ vh.favoriteIcon.setVisibility(View.GONE); } vh.progress.setVisibility(View.GONE); switch (status) { case SyncContentStatus.STATUS_PENDING: displayStatut(vh, R.drawable.sync_status_pending); break; case SyncContentStatus.STATUS_RUNNING: displayStatut(vh, R.drawable.sync_status_loading); vh.progress.setVisibility(View.VISIBLE); vh.favoriteIcon.setVisibility(View.GONE); long totalSize = cursor.getLong(SyncContentSchema.COLUMN_TOTAL_SIZE_BYTES_ID); if (totalSize == -1) { vh.progress.setIndeterminate(true); } else { long progress = cursor.getLong(SyncContentSchema.COLUMN_BYTES_DOWNLOADED_SO_FAR_ID); float value = (((float) progress / ((float) totalSize)) * 100); int percentage = Math.round(value); vh.progress.setIndeterminate(false); vh.progress.setMax(100); vh.progress.setProgress(percentage); } break; case SyncContentStatus.STATUS_HIDDEN: vh.favoriteIcon.setVisibility(View.GONE); vh.iconRight.setVisibility(View.GONE); break; case SyncContentStatus.STATUS_PAUSED: displayStatut(vh, R.drawable.sync_status_pending); break; case SyncContentStatus.STATUS_MODIFIED: displayStatut(vh, R.drawable.sync_status_pending); break; case SyncContentStatus.STATUS_SUCCESSFUL: displayStatut(vh, R.drawable.sync_status_success); break; case SyncContentStatus.STATUS_FAILED: displayStatut(vh, R.drawable.sync_status_failed); break; case SyncContentStatus.STATUS_CANCEL: displayStatut(vh, R.drawable.sync_status_failed); break; case SyncContentStatus.STATUS_REQUEST_USER: displayStatut(vh, R.drawable.sync_status_failed); break; default: break; } if (selectedItems != null && selectedItems.contains(nodeId)) { UIUtils.setBackground(((View) vh.icon.getParent()), context.getResources().getDrawable(R.drawable.list_longpressed_holo)); } else { UIUtils.setBackground(((View) vh.icon.getParent()), null); } if (SyncContentStatus.STATUS_RUNNING != status) { vh.bottomText.setVisibility(View.VISIBLE); vh.bottomText.setText(createContentBottomText(context, cursor)); AccessibilityUtils.addContentDescription(vh.bottomText, createContentDescriptionBottomText(context, cursor)); } else { vh.bottomText.setVisibility(View.GONE); } if (mode == SyncFragment.MODE_LISTING && fragmentRef.get().getActivity() instanceof MainActivity) { if (status != SyncContentStatus.STATUS_REQUEST_USER) { UIUtils.setBackground(vh.choose, null); return; } vh.choose.setImageResource(R.drawable.ic_more_options); vh.choose.setBackgroundResource(R.drawable.alfrescohololight_list_selector_holo_light); int d_16 = DisplayUtils.getPixels(context, R.dimen.d_16); vh.choose.setPadding(d_16, d_16, d_16, d_16); vh.choose.setVisibility(View.VISIBLE); vh.choose.setTag(R.id.node_action, nodeId); vh.choose.setTag(R.id.favorite_id, favoriteId); vh.choose.setTag(R.id.operation_status, status); vh.choose.setTag(R.id.is_synced, syncRoot); AccessibilityUtils.addContentDescription(vh.choose, String.format(context.getString(R.string.more_options_favorite), cursor.getString(SyncContentSchema.COLUMN_TITLE_ID))); vh.choose.setOnClickListener(new OnClickListener() { @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onClick(View v) { String item = (String) v.getTag(R.id.node_action); Integer statut = (Integer) v.getTag(R.id.operation_status); long favoriteId = (Long) v.getTag(R.id.favorite_id); boolean rootSynced = (Boolean) v.getTag(R.id.is_synced); selectedOptionItems.add(item); selectedOptionItemId.add(favoriteId); PopupMenu popup = new PopupMenu(context, v); getMenu(popup.getMenu(), statut, rootSynced); popup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { selectedOptionItems.clear(); } }); popup.setOnMenuItemClickListener(SyncCursorAdapter.this); popup.show(); } }); } else { UIUtils.setBackground(vh.choose, null); } }
From source file:systems.soapbox.ombuds.client.ui.BlockListFragment.java
@Override public void onBlockMenuClick(final View view, final StoredBlock block) { final PopupMenu popupMenu = new PopupMenu(activity, view); popupMenu.inflate(R.menu.blocks_context); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override/*w ww. j av a2s . co m*/ public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.blocks_context_browse: startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(config.getBlockExplorer(), "block/" + block.getHeader().getHashAsString()))); return true; } return false; } }); popupMenu.show(); }
From source file:com.fastbootmobile.encore.app.adapters.SearchAdapter.java
private void showPlaylistOverflow(final Context context, View parent, final Playlist playlist) { PopupMenu popupMenu = new PopupMenu(context, parent); popupMenu.inflate(R.menu.search_res_playlist); popupMenu.show(); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override// w w w. jav a 2s . c om public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_play_now: PlaybackProxy.playPlaylist(playlist); break; case R.id.menu_add_to_queue: PlaybackProxy.queuePlaylist(playlist, false); break; case R.id.menu_add_to_playlist: PlaylistChooserFragment fragment = PlaylistChooserFragment.newInstance(playlist); fragment.show(((FragmentActivity) context).getSupportFragmentManager(), playlist.getRef()); break; default: return false; } return true; } }); }