List of usage examples for android.widget PopupMenu show
public void show()
From source file:de.enlightened.peris.ForumSettingsFragment.java
private void setupHomeButton(final SharedPreferences appPreferences) { //Home Page button final LinearLayout forumSettingHome = (LinearLayout) getActivity().findViewById(R.id.forum_setting_home); forumSettingHome.setOnClickListener(new View.OnClickListener() { @Override/* www .j a v a2s . c om*/ @SuppressWarnings("checkstyle:requirethis") public void onClick(final View v) { final PopupMenu popup = new PopupMenu(getActivity(), v); final MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.home_page_selection, popup.getMenu()); popup.setOnMenuItemClickListener(forumHomeSelectedListener); popup.show(); } }); //Home Page Display Text final String currentServerId = this.application.getSession().getServer().serverId; final String keyName = currentServerId + "_home_page"; String valueName = getString(R.string.subforum_id); String displayName = "Forum Index"; valueName = appPreferences.getString(keyName, getString(R.string.subforum_id)); if (valueName.contentEquals(getString(R.string.subforum_id))) { displayName = "Forum Index"; } if (valueName.contentEquals("forum_favs")) { displayName = "Favorites"; } if (valueName.contentEquals("timeline")) { displayName = "Timeline"; } if (valueName.contentEquals("participated")) { displayName = "Participated Topics"; } if (valueName.contentEquals("favs")) { displayName = "Subscribed Topics"; } if (valueName.contentEquals("unread")) { displayName = "Unread Topics"; } final TextView forumSettingHomeCurrent = (TextView) this.getActivity() .findViewById(R.id.forum_setting_home_current); forumSettingHomeCurrent.setText(displayName); }
From source file:com.owncloud.android.ui.fragment.FileDetailSharingFragment.java
@OnClick(R.id.overflow_menu_share_link) public void showLinkOverflowMenu() { Context context = getContext(); if (context != null && ThemeUtils.themingEnabled(context)) { // use grey as fallback for elements where custom theming is not available context.getTheme().applyStyle(R.style.FallbackThemingTheme, true); } else {/*from ww w.ja va 2 s. co m*/ context = getActivity(); } PopupMenu popup = new PopupMenu(context, overflowMenuShareLink); popup.inflate(R.menu.file_detail_sharing_link_menu); prepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(this::optionsItemSelected); popup.show(); }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.LibraryCursorAdapter.java
@Override protected void updateIcon(TwoLinesViewHolder vh, Cursor cursor) { String data = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA)); File f = new File(data); switch (mediaTypeId) { case MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE: vh.icon.setImageResource(R.drawable.mime_img); renditionManager.getPicasso().load(f).resize(150, 150).centerCrop().placeholder(R.drawable.mime_256_img) .error(R.drawable.mime_256_img).into(vh.icon); break;/*from ww w . j a va2 s. co m*/ case MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO: vh.icon.setImageResource(R.drawable.mime_video); break; case MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO: vh.icon.setImageResource(R.drawable.mime_audio); break; default: Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA))); vh.icon.setImageResource(MimeTypeManager.getInstance(context).getIcon(uri.getLastPathSegment())); break; } if (mode == FileExplorerFragment.MODE_LISTING && fragmentRef.get().getActivity() instanceof MainActivity) { 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, f); 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(context, v); getMenu(popup.getMenu(), item); popup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { selectedOptionItems.clear(); } }); popup.setOnMenuItemClickListener(LibraryCursorAdapter.this); popup.show(); } }); } else { UIUtils.setBackground(vh.choose, null); vh.choose.setVisibility(View.GONE); } }
From source file:com.atlas.mars.weatherradar.MainActivity.java
@Override public void onClick(View v) { final View _v = v; final MainActivity mainActivity = this; switch (v.getId()) { case R.id.buttonReload: /* MyFragment myFragment = (MyFragment)fragmetMap.get(posinion);// (MyFragment)pager.getChildAt(posinion); myFragment.reloadImg();*/ mapFragments.get(posinion).reloadImg(); // reloadImg(); break;/*from ww w. j av a 2 s .c om*/ case R.id.buttonMenu: PopupMenu popupMenu = new PopupMenu(this, v); popupMenu.inflate(R.menu.menu_main); popupMenu.show(); popupMenu.setOnMenuItemClickListener(this); break; } }
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) *//* ww w . j a v a 2s. 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:com.battlelancer.seriesguide.ui.MoviesWatchListFragment.java
@Override public void onPopupMenuClick(View v, final int movieTmdbId) { PopupMenu popupMenu = new PopupMenu(v.getContext(), v); popupMenu.getMenu().add(0, CONTEXT_WATCHLIST_REMOVE_ID, 0, R.string.watchlist_remove); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/* ww w . j a va 2s.co m*/ public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case CONTEXT_WATCHLIST_REMOVE_ID: { MovieTools.removeFromWatchlist(getActivity(), movieTmdbId); fireTrackerEvent("Remove from watchlist"); return true; } } return false; } }); popupMenu.show(); }
From source file:com.battlelancer.seriesguide.ui.MoviesCollectionFragment.java
@Override public void onPopupMenuClick(View v, final int movieTmdbId) { PopupMenu popupMenu = new PopupMenu(v.getContext(), v); popupMenu.getMenu().add(0, CONTEXT_COLLECTION_REMOVE_ID, 0, R.string.action_collection_remove); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/* w w w. j a v a2 s .c om*/ public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case CONTEXT_COLLECTION_REMOVE_ID: { MovieTools.removeFromCollection(getActivity(), movieTmdbId); fireTrackerEvent("Remove from collection"); return true; } } return false; } }); popupMenu.show(); }
From source file:net.nakama.duckdroid.ui.Duckdroid.java
public void btnshowPopupBang(View view) { PopupMenu p = new PopupMenu(this, view); MenuInflater inflater = p.getMenuInflater(); p.setOnMenuItemClickListener(bangListener); inflater.inflate(this.prefBangMenuId, p.getMenu()); p.show(); }
From source file:net.nakama.duckdroid.ui.Duckdroid.java
public void btnshowPopupSetting(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); popup.setOnMenuItemClickListener(this); inflater.inflate(R.menu.activity_duckdroid, popup.getMenu()); popup.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 a2 s .c om 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); } }