Java Code Examples for android.widget.PopupMenu#show()
The following examples show how to use
android.widget.PopupMenu#show() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GotoMenu.java From Onosendai with Apache License 2.0 | 6 votes |
@Override public void onClick (final View v) { final PopupMenu mnu = new PopupMenu(this.mainActivity, v); final Config conf = this.mainActivity.getConf(); final List<Column> columns = conf.getColumns(); final Set<Integer> columnsHidingRetweets = conf.getColumnsHidingRetweets(); int i = 0; for (final Column col : columns) { final MenuItem menuItem = mnu.getMenu().add(Menu.NONE, MNU_GOTO_BASE_ID + i, Menu.NONE, col.getTitle()); final ScrollState scroll = this.mainActivity.getColumnScroll(col.getId()); new UnreadCountLoaderTask(this.mainActivity.getDb(), col, columnsHidingRetweets, this.mainActivity.isShowFiltered(), menuItem, scroll) .executeOnExecutor(this.mainActivity.getLocalEs()); i++; } mnu.setOnMenuItemClickListener(new GotoItemClientListener(columns, this.mainActivity)); mnu.show(); }
Example 2
Source File: MainActivity.java From cidrawing with Apache License 2.0 | 6 votes |
public void changeColor(View v) { PopupMenu popup = new PopupMenu(this, v); popup.getMenuInflater().inflate(R.menu.menu_color, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.black_menu: drawingBoard.getDrawingContext().getPaint().setColor(Color.BLACK); break; case R.id.blue_menu: drawingBoard.getDrawingContext().getPaint().setColor(Color.BLUE); break; case R.id.red_menu: drawingBoard.getDrawingContext().getPaint().setColor(Color.RED); break; } return true; } }); popup.show(); }
Example 3
Source File: StatusAdapter.java From xifan with Apache License 2.0 | 6 votes |
private void showPopupMenu(View view, final StatusRes statusRes) { PopupMenu popupMenu = new PopupMenu(mContext, view); if (statusRes.isIs_self()) { popupMenu.inflate(R.menu.menu_item_status_self); } else { popupMenu.inflate(R.menu.menu_item_status); } popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_delete: showDeleteStatusDailog(statusRes); break; case R.id.action_copy: copyStatus(statusRes); break; case R.id.action_share: break; } return false; } }); popupMenu.show(); }
Example 4
Source File: CompetitionFeedItemView.java From 1Rramp-Android with MIT License | 6 votes |
private void showPopup() { int menu_res_id; menu_res_id = R.menu.competition_post_menu_with_delete; ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getContext(), R.style.PopupMenuOverlapAnchor); PopupMenu popup = new PopupMenu(contextThemeWrapper, popupMenuDots); popup.getMenuInflater().inflate(menu_res_id, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.delete) { showAlertDialogForDelete(); return true; } return false; } }); popup.show(); }
Example 5
Source File: ArtistListFragment.java From Kore with Apache License 2.0 | 6 votes |
@Override public void onClick(final View v) { final ViewHolder viewHolder = (ViewHolder)v.getTag(); final PlaylistType.Item playListItem = new PlaylistType.Item(); playListItem.artistid = viewHolder.dataHolder.getId(); final PopupMenu popupMenu = new PopupMenu(fragment.getContext(), v); popupMenu.getMenuInflater().inflate(R.menu.musiclist_item, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_play: MediaPlayerUtils.play(fragment, playListItem); return true; case R.id.action_queue: MediaPlayerUtils.queue(fragment, playListItem, PlaylistType.GetPlaylistsReturnType.AUDIO); return true; } return false; } }); popupMenu.show(); }
Example 6
Source File: FieldAdapter.java From Field-Book with GNU General Public License v2.0 | 5 votes |
private View.OnClickListener makeMenuPopListener(final int position) { return new View.OnClickListener() { // Do it when clicking ":" @Override public void onClick(final View view) { PopupMenu popup = new PopupMenu(FieldEditorActivity.thisActivity, view); //Inflating the Popup using xml file popup.getMenuInflater().inflate(R.menu.menu_field_listitem, popup.getMenu()); //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(makeSelectMenuListener(position)); popup.show();//showing popup menu } }; }
Example 7
Source File: PostActivity.java From Ruisi with Apache License 2.0 | 5 votes |
@Override public void onListItemClick(View v, final int position) { switch (v.getId()) { case R.id.btn_reply_cz: if (isLogin()) { SingleArticleData single = datas.get(position); Intent i = new Intent(PostActivity.this, ReplyCzActivity.class); i.putExtra("islz", single.uid == datas.get(0).uid); i.putExtra("data", single); startActivityForResult(i, 20); } break; case R.id.need_loading_item: refresh(); break; case R.id.btn_more: clickPosition = position; PopupMenu popup = new PopupMenu(this, v); popup.setOnMenuItemClickListener(this); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_post_more, popup.getMenu()); //判断是不是自己 if (!datas.get(position).canManage && (!App.isLogin(this) || !App.getUid(this).equals(datas.get(position).uid))) { popup.getMenu().removeItem(R.id.tv_edit); } //如果有管理权限,则显示除了关闭之外的全部按钮 if (!datas.get(position).canManage) { popup.getMenu().removeGroup(R.id.menu_manege); } popup.show(); break; default: break; } }
Example 8
Source File: BrowseForumActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void menu(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_browse_forum, popup.getMenu()); onPrepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); popup.show(); }
Example 9
Source File: AvatarEditorActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void menu(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_avatar_editor, popup.getMenu()); onPrepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); popup.show(); }
Example 10
Source File: BrowseActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void menu(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_browse, popup.getMenu()); onPrepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); popup.show(); }
Example 11
Source File: CustomActionsPopup.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
public boolean show() { List<AccessibilityAction> actions = getActionList(); if (actions.isEmpty()) { return false; } PopupMenu popup = new PopupMenu(mLauncher, mIcon); popup.setOnMenuItemClickListener(this); Menu menu = popup.getMenu(); for (AccessibilityAction action : actions) { menu.add(Menu.NONE, action.getId(), Menu.NONE, action.getLabel()); } popup.show(); return true; }
Example 12
Source File: BotActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void menu(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_bot, popup.getMenu()); onPrepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); popup.show(); }
Example 13
Source File: ViewUserActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void menu(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_view_user, popup.getMenu()); onPrepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); popup.show(); }
Example 14
Source File: ViewUserActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void menu(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_view_user, popup.getMenu()); onPrepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); popup.show(); }
Example 15
Source File: AvatarEditorActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void menu(View view) { PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.layout.menu_avatar_editor, popup.getMenu()); onPrepareOptionsMenu(popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return onOptionsItemSelected(item); } }); popup.show(); }
Example 16
Source File: TracksSubFragment.java From Rey-MusicPlayer with Apache License 2.0 | 4 votes |
public void onPopUpMenuClickListener(View v, final int position) { mSelectedPosition = position; PopupMenu menu = new PopupMenu(getActivity(), v); SubMenu sub = (menu.getMenu()).addSubMenu(0, ADD_TO_PLAYLIST, 1, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), sub, 0); menu.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.popup_song_play_next: new AsyncAddTo(mSongList.get(position)._title, false, mSongList.get(position)).execute(); break; case R.id.popup_song_addto_queue: new AsyncAddTo(mSongList.get(position)._title, true, mSongList.get(position)).execute(); break; case R.id.popup_song_add_to_favs: mApp.getDBAccessHelper().addToFavorites(mSongList.get(position)); break; case R.id.popup_song_delete: ArrayList<Song> song = new ArrayList<>(); song.add(mSongList.get(mSelectedPosition)); try { MusicUtils.deleteFile(this, song, this); } catch (IndexOutOfBoundsException e) { e.printStackTrace(); } break; case R.id.popup_song_use_as_phone_ringtone: MusicUtils.setRingtone((AppCompatActivity) getActivity(), mSongList.get(mSelectedPosition)._id); break; case R.id.popup_song_share: MusicUtils.shareTheMusic(getActivity(), mSongList.get(mSelectedPosition)._path); break; case R.id.popup_edit_songs_tags: Intent intent = new Intent(getActivity(), Id3TagEditorActivity.class); intent.putExtra("SONG_PATH", mSongList.get(mSelectedPosition)._path); intent.putExtra("ALBUM_ID", mSongList.get(mSelectedPosition)._albumId); startActivityForResult(intent, Constants.EDIT_TAGS); break; case NEW_PLAYLIST: PlaylistDialog playlistDialog = new PlaylistDialog(); Bundle bundle = new Bundle(); bundle.putLongArray("PLAYLIST_IDS", new long[]{mSongList.get(mSelectedPosition)._id}); playlistDialog.setArguments(bundle); playlistDialog.show(getChildFragmentManager(), "FRAGMENT_TAG"); return true; case PLAYLIST_SELECTED: long[] list = new long[]{mSongList.get(mSelectedPosition)._id}; long playlist = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(Common.getInstance(), list, playlist); return true; } return false; }); menu.inflate(R.menu.popup_song); menu.show(); }
Example 17
Source File: PlayerActivity.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
public void showVideoPopup(View v) { PopupMenu popup = new PopupMenu(this, v); configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO); popup.show(); }
Example 18
Source File: FolderFragment.java From Rey-MusicPlayer with Apache License 2.0 | 4 votes |
public void onPopUpMenuClickListener(View v, final int position) { final PopupMenu menu = new PopupMenu(getActivity(), v); SubMenu sub = (menu.getMenu()).addSubMenu(0, ADD_TO_PLAYLIST, 1, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), sub, 0); menu.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.popup_song_play_next: new AsyncAddTo(fetchedFiles.get(position)._title, false, fetchedFiles.get(position)).execute(); break; case R.id.popup_song_addto_queue: new AsyncAddTo(fetchedFiles.get(position)._title, true, fetchedFiles.get(position)).execute(); break; case R.id.popup_song_add_to_favs: mApp.getDBAccessHelper().addToFavorites(fetchedFiles.get(position)); break; case R.id.popup_song_delete: ArrayList<Song> song = new ArrayList<>(); song.add(fetchedFiles.get(position)); MusicUtils.deleteFile(FolderFragment.this, song, onTaskCompleted); break; case R.id.popup_song_use_as_phone_ringtone: MusicUtils.setRingtone((AppCompatActivity) getActivity(), fetchedFiles.get(position)._id); break; case R.id.popup_song_share: MusicUtils.shareTheMusic(FolderFragment.this.getActivity(), fetchedFiles.get(position)._path); break; case NEW_PLAYLIST: PlaylistDialog playlistDialog = new PlaylistDialog(); Bundle bundle = new Bundle(); bundle.putLongArray("PLAYLIST_IDS", new long[]{fetchedFiles.get(position)._id}); playlistDialog.setArguments(bundle); playlistDialog.show(getActivity().getSupportFragmentManager(), "FRAGMENT_TAG"); return true; case PLAYLIST_SELECTED: long[] list = new long[]{fetchedFiles.get(position)._id}; long playlist = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getContext(), list, playlist); return true; } return false; }); menu.inflate(R.menu.popup_song); menu.show(); }
Example 19
Source File: TracksSubFragment.java From Rey-MusicPlayer with Apache License 2.0 | 4 votes |
private void onPopUpClicked(View view) { final PopupMenu menu = new PopupMenu(getActivity(), view); SubMenu sub = (menu.getMenu()).addSubMenu(0, ADD_TO_PLAYLIST, 1, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), sub, 0); menu.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.menu_play_next: if (mSongList.size() != 0) { new AsyncAddTo(HEADER_TITLE, false, mSongList).execute(); } break; case R.id.menu_shuffle: if (mSongList.size() != 0) { mApp.getPlayBackStarter().shuffleUp(mSongList); } break; case R.id.menu_add_to_queue: if (mSongList.size() != 0) { new AsyncAddTo(HEADER_TITLE, true, mSongList).execute(); } break; case R.id.menu_edit_tags: Toast.makeText(mContext, "Need to be implemented.", Toast.LENGTH_SHORT).show(); break; case R.id.action_search: Intent intent = new Intent(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, HEADER_TITLE); startActivity(intent); break; case NEW_PLAYLIST: PlaylistDialog playlistDialog = new PlaylistDialog(); Bundle bundle = new Bundle(); bundle.putLongArray("PLAYLIST_IDS", MusicUtils.getPlayListIds(mSongList)); playlistDialog.setArguments(bundle); playlistDialog.show(getChildFragmentManager(), "FRAGMENT_TAG"); break; case PLAYLIST_SELECTED: MusicUtils.insertIntoPlayList(mContext, item, mSongList); break; case R.id.menu_delete: try { MusicUtils.deleteFile(TracksSubFragment.this, mSongList, this); } catch (IndexOutOfBoundsException e) { e.printStackTrace(); } break; } return false; }); menu.inflate(R.menu.popup_sub_list_menu); menu.getMenu().findItem(R.id.menu_edit_tags).setVisible(false); menu.show(); }
Example 20
Source File: PlayerActivity.java From Android-Example-HLS-ExoPlayer with Apache License 2.0 | 4 votes |
public void showTextPopup(View v) { PopupMenu popup = new PopupMenu(this, v); configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT); popup.show(); }