List of usage examples for android.widget PopupMenu PopupMenu
public PopupMenu(Context context, View anchor)
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 . ja va 2 s . c o m @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: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 ww w . ja va 2s .c o m*/ 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:com.cerema.cloud2.ui.fragment.OCFileListFragment.java
private void showFileAction(int fileIndex) { Bundle args = getArguments();//from w ww. j a v a 2s . co m PopupMenu pm = new PopupMenu(getActivity(), null); Menu menu = pm.getMenu(); boolean allowContextualActions = (args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true); if (allowContextualActions) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.file_actions_menu, menu); OCFile targetFile = (OCFile) mAdapter.getItem(fileIndex); if (mContainerActivity.getStorageManager() != null) { FileMenuFilter mf = new FileMenuFilter(targetFile, mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity()); mf.filter(menu); } /// TODO break this direct dependency on FileDisplayActivity... if possible MenuItem item = menu.findItem(R.id.action_open_file_with); FileFragment frag = ((FileDisplayActivity) getActivity()).getSecondFragment(); if (frag != null && frag instanceof FileDetailFragment && frag.getFile().getFileId() == targetFile.getFileId()) { item = menu.findItem(R.id.action_see_details); if (item != null) { item.setVisible(false); item.setEnabled(false); } } FileActionsDialogFragment dialog = FileActionsDialogFragment.newInstance(menu, fileIndex, targetFile.getFileName()); dialog.setTargetFragment(this, 0); dialog.show(getFragmentManager(), FileActionsDialogFragment.FTAG_FILE_ACTIONS); } }
From source file:me.albertonicoletti.latex.activities.EditorActivity.java
/** * Initializes the symbols shortcut bar. *//*from w w w . java 2 s. c o m*/ private void initSymbols() { // It actually only initializes the "+" button, creating a popup menu final Button button = (Button) findViewById(R.id.maths_button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Shows a popup menu PopupMenu popup = new PopupMenu(EditorActivity.this, button); popup.getMenuInflater().inflate(R.menu.menu_maths, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { // On symbol click insertSymbol(menuItem.getTitle().toString()); return false; } }); popup.show(); } }); }
From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java
/** * Show a menu to enable or disable sensors. */// w ww . ja v a2s . co m private void showSensorMenu() { View menuView = findViewById(R.id.action_sensors); PopupMenu popup = new PopupMenu(menuView.getContext(), menuView); final List<ISensorPlugin> plugins = ExperimentPluginFactory.getFactory().getSensorPlugins(); for (int i = 0; i < plugins.size(); i++) { ISensorPlugin plugin = plugins.get(i); MenuItem item = popup.getMenu().add(1, i, i, plugin.getSensorName()); item.setCheckable(true); if (getExperiment(plugin) != null) item.setChecked(true); } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { ISensorPlugin plugin = plugins.get(menuItem.getItemId()); IExperimentSensor experimentSensor = getExperiment(plugin); if (experimentSensor != null) removeExperimentRun(experimentSensor); else addExperiment(plugin); return true; } }); popup.show(); }
From source file:com.zigvine.zagriculture.UIActivity.java
@TargetApi(11) private void showPopupMenu() { final PopupMenu popupMenu = new PopupMenu(this, mOverflowMenuButton); final Menu menu = popupMenu.getMenu(); // popupMenu.inflate(R.menu.main_menu); popupMenu.getMenuInflater().inflate(R.menu.main_menu, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//from www . ja va 2s . c om public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); onPrepareOptionsMenu(menu); if (popupMenu != null) { popupMenu.show(); } }
From source file:com.inde.shiningdays.MainActivity.java
private void showPopupMenu() { final View menuItemView = findViewById(R.id.action_menumore); // SAME ID AS MENU ID PopupMenu popupMenu = new PopupMenu(this, menuItemView); popupMenu.inflate(R.menu.more_popup_menu); String currentSortRule = getCurrentSortRule(); if (CountDown.SORT_END_DATE_ASC.equals(currentSortRule)) { popupMenu.getMenu().findItem(R.id.sort_end_date_asc).setChecked(true); } else if (CountDown.DEFAULT_SORT_ORDER.equals(currentSortRule)) { popupMenu.getMenu().findItem(R.id.sort_update_date_desc).setChecked(true); }// w ww . j a v a 2 s . c o m popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { String rule = ""; switch (item.getItemId()) { case R.id.sort_end_date_asc: rule = CountDown.SORT_END_DATE_ASC; updateCurrentSortRule(rule); selectItem(currentTypePosition, rule); return true; case R.id.sort_update_date_desc: rule = CountDown.DEFAULT_SORT_ORDER; updateCurrentSortRule(rule); selectItem(currentTypePosition, rule); return true; case R.id.action_setting: Intent intent = new Intent(menuItemView.getContext(), MenuMore.class); startActivity(intent); default: return true; } } }); popupMenu.show(); }
From source file:org.videolan.vlc2.gui.video.VideoGridFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onContextPopupMenu(View anchor, final int position) { if (!LibVlcUtil.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick();/*from w w w . jav a 2 s .c om*/ return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu()); Media media = mVideoAdapter.getItem(position); setContextMenuItems(popupMenu.getMenu(), media); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
From source file:syncthing.android.ui.sessionsettings.SettingsPresenter.java
public void showApiKeyOverflow(final View btn) { PopupMenu m = new PopupMenu(btn.getContext(), btn); m.inflate(R.menu.apikey_overflow);//from w w w .jav a 2 s. c om m.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.copy: copyApiKey(btn); return true; case R.id.generate: regenApiKey(btn); return true; default: return false; } } }); m.show(); }
From source file:org.xbmc.kore.ui.sections.audio.SongsListFragment.java
private void showPopupMenu(View v) { final ViewHolder viewHolder = (ViewHolder) v.getTag(); final PlaylistType.Item playListItem = new PlaylistType.Item(); playListItem.songid = viewHolder.songInfo.songId; final PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.song_item, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/*from w ww. j av a 2 s . co m*/ public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_play_song: MediaPlayerUtils.play(SongsListFragment.this, playListItem); return true; case R.id.action_add_to_playlist: MediaPlayerUtils.queue(SongsListFragment.this, playListItem, PlaylistType.GetPlaylistsReturnType.AUDIO); return true; case R.id.download: ArrayList<FileDownloadHelper.SongInfo> songInfoList = new ArrayList<>(); songInfoList.add(viewHolder.songInfo); UIUtils.downloadSongs(getActivity(), songInfoList, HostManager.getInstance(getActivity()).getHostInfo(), callbackHandler); } return false; } }); popupMenu.show(); }