List of usage examples for android.view MenuItem setOnMenuItemClickListener
public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener);
From source file:com.glabs.homegenie.fragments.GroupsViewFragment.java
public void UpdateJumpToGroupMenu(ArrayList<Group> groups) { StartActivity rootactivity = (StartActivity) getActivity(); if (rootactivity != null) { Menu menu = rootactivity.getActionMenu(); if (menu != null) { MenuItem jumpto = menu.findItem(R.id.action_jumpto); Menu submenu = jumpto.getSubMenu(); if (submenu == null) return; ////from w w w . j a va 2s.c o m submenu.removeGroup(Menu.NONE); if (groups.size() > 0) { int gid = 0; for (Group group : groups) { MenuItem grp = submenu.add(Menu.NONE, gid, gid, group.Name); // prg.setIcon(R.drawable.ic_action_flash_on); MenuCompat.setShowAsAction(grp, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT); grp.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { mIndicator.setCurrentItem(menuItem.getItemId()); return true; } }); gid++; } } } } }
From source file:com.orpheusdroid.screenrecorder.VideosListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem refresh = menu.add("Refresh"); refresh.setIcon(R.drawable.ic_refresh_white_24dp); refresh.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS); refresh.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*from ww w . ja v a 2 s .c o m*/ public boolean onMenuItemClick(MenuItem menuItem) { // Prevent repeated refresh requests if (swipeRefreshLayout.isRefreshing()) return false; videosList.clear(); checkPermission(); Log.d(Const.TAG, "Refreshing"); return false; } }); }
From source file:pl.bcichecki.rms.client.android.fragments.OutboxMessagesListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); getActivity().getMenuInflater().inflate(R.menu.fragment_outbox_messages_list, menu); MenuItem showArchivedMenuItem = menu.findItem(R.id.fragment_outbox_messages_list_menu_show_archived); showArchivedMenuItem.setChecked(showArchivedMessages); showArchivedMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//from w ww.ja v a2 s . com public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedMessages = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
From source file:pl.bcichecki.rms.client.android.fragments.InboxMessagesListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); getActivity().getMenuInflater().inflate(R.menu.fragment_inbox_messages_list, menu); MenuItem showArchivedMenuItem = menu.findItem(R.id.fragment_inbox_messages_list_menu_show_archived); showArchivedMenuItem.setChecked(showArchivedMessages); showArchivedMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*ww w . j a v a 2s.c o m*/ public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedMessages = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPCompaniesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem searchBtn = menu.findItem(R.id.action_search); searchBtn.setVisible(true);// ww w . ja v a2 s . c om SubMenu selectionMenu = menu.addSubMenu(getResources().getString(R.string.selection_options_btn)); selectionMenu.getItem().setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_edit) .colorRes(R.color.accentNoTransparency).actionBarSize()); selectionMenu.getItem().setTitle(getResources().getString(R.string.selection_options_btn)); selectionMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); MenuItem selectAllItem = selectionMenu.add(getResources().getString(R.string.btn_select_all)); selectAllItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_check_square_o) .colorRes(R.color.accentNoTransparency).actionBarSize()); selectAllItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); selectAllItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getActivity(), "Selected all items", Toast.LENGTH_SHORT).show(); try { DBManager.setFilteredCompaniesSelected(true); } catch (SQLException e) { e.printStackTrace(); } ((CompaniesCellAdapter) recyclerView.getAdapter()).refreshData(); synchronized (RHCareerFairLayout.refreshMapNotifier) { RHCareerFairLayout.refreshMapNotifier.notifyChanged(); } return true; } }); MenuItem deselectAllItem = selectionMenu.add(getResources().getString(R.string.btn_deselect_all)); deselectAllItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_square_o) .colorRes(R.color.accentNoTransparency).actionBarSize()); deselectAllItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); deselectAllItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getActivity(), "Deselected all items", Toast.LENGTH_SHORT).show(); try { DBManager.setFilteredCompaniesSelected(false); } catch (SQLException e) { e.printStackTrace(); } ((CompaniesCellAdapter) recyclerView.getAdapter()).refreshData(); synchronized (RHCareerFairLayout.refreshMapNotifier) { RHCareerFairLayout.refreshMapNotifier.notifyChanged(); } return true; } }); }
From source file:com.kaliturin.blacklist.fragments.SMSConversationFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.main, menu); MenuItem menuItem = menu.findItem(R.id.write_message); Utils.setMenuIconTint(getContext(), menuItem, R.attr.colorAccent); menuItem.setVisible(true);// w w w . j a v a 2s .c om menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { // open activity with fragment of sending SMS openSMSSendActivity(contactName, contactNumber, messageEdit.getText().toString()); messageEdit.setText(""); return true; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.bitants.wally.fragments.RandomImagesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.images_random, menu); MenuItem menuItemRefresh = menu.findItem(R.id.action_refresh); if (menuItemRefresh != null) { menuItemRefresh.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/* www . ja v a2s . co m*/ public boolean onMenuItemClick(MenuItem item) { showLoader(); onRefresh(); return false; } }); } MenuItem menuItemFilter = menu.findItem(R.id.action_filter); if (menuItemFilter != null) { menuItemFilter.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager != null) { final FilterDialogFragment filterDialogFragment = new FilterDialogFragment(); filterDialogFragment.setPrimaryColor(getAppBarColor()); filterDialogFragment.setPositiveButton(R.string.submit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (filterDialogFragment.saveChanges()) { WallyApplication.getContext().sendBroadcast( new Intent(FiltersChangeReceiver.FILTERS_CHANGED)); } } }); filterDialogFragment.setNegativeButton(R.string.cancel, null); filterDialogFragment.show(fragmentManager, FilterDialogFragment.TAG); } return false; } }); } super.onCreateOptionsMenu(menu, inflater); }
From source file:org.wikipedia.page.shareafact.ShareHandler.java
/** * @param mode ActionMode under which this context is starting. *//*from www . j av a 2s .c o m*/ public void onTextSelected(ActionMode mode) { webViewActionMode = mode; Menu menu = mode.getMenu(); MenuItem shareItem = menu.findItem(R.id.menu_text_select_share); if (Prefs.isShareTutorialEnabled()) { postShowShareToolTip(shareItem); Prefs.setShareTutorialEnabled(false); } // Provide our own listeners for the copy, define, and share buttons. shareItem.setOnMenuItemClickListener(new RequestTextSelectOnMenuItemClickListener(PAYLOAD_PURPOSE_SHARE)); MenuItem copyItem = menu.findItem(R.id.menu_text_select_copy); copyItem.setOnMenuItemClickListener((MenuItem menuItem) -> { fragment.getWebView().copyToClipboard(); FeedbackUtil.showMessage(fragment.getActivity(), R.string.text_copied); leaveActionMode(); return true; }); MenuItem defineItem = menu.findItem(R.id.menu_text_select_define); if (shouldEnableWiktionaryDialog()) { defineItem.setVisible(true); defineItem.setOnMenuItemClickListener( new RequestTextSelectOnMenuItemClickListener(PAYLOAD_PURPOSE_DEFINE)); } MenuItem editItem = menu.findItem(R.id.menu_text_edit_here); editItem.setOnMenuItemClickListener( new RequestTextSelectOnMenuItemClickListener(PAYLOAD_PURPOSE_EDIT_HERE)); if (!fragment.getPage().isArticle()) { editItem.setVisible(false); } if (funnel == null) { createFunnel(); } funnel.logHighlight(); }
From source file:com.streaming.sweetplayer.PlayerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.player_options_menu, menu); inflater.inflate(R.menu.share_menu, menu); MenuItem shareItem = menu.findItem(R.id.item_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem); mShareActionProvider.setShareIntent(getDefaultIntent()); //mShareActionProvider.setShareHistoryFileName(null); MenuItem viewLyricsMenuItem = menu.findItem(R.id.item_view_lyrics); if (viewLyricsMenuItem != null) { viewLyricsMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { if (PlayerService.checkSongsList()) { new GetSongDetailTask().execute(); }/*from w w w . j a v a 2s . co m*/ return true; } }); } mAddMenuItem = menu.findItem(R.id.item_add_to_playlist); if (mDataBase.isOnPlayList(sSongId)) { mAddMenuItem.setVisible(false); } else { mAddMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { addToPlaylist(); return true; } }); } return super.onCreateOptionsMenu(menu); }