List of usage examples for android.view MenuItem setTitle
public MenuItem setTitle(@StringRes int title);
From source file:io.plaidapp.ui.HomeActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { final MenuItem dribbbleLogin = menu.findItem(R.id.menu_dribbble_login); if (dribbbleLogin != null) { dribbbleLogin .setTitle(dribbblePrefs.isLoggedIn() ? R.string.dribbble_log_out : R.string.dribbble_login); }//from w ww. j a v a 2 s.c o m final MenuItem designerNewsLogin = menu.findItem(R.id.menu_designer_news_login); if (designerNewsLogin != null) { designerNewsLogin.setTitle( designerNewsPrefs.isLoggedIn() ? R.string.designer_news_log_out : R.string.designer_news_login); } return true; }
From source file:me.acristoffers.tracker.activities.PackageListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final int id = item.getItemId(); switch (id) { case R.id.check_for_updates: packageListFragment.checkForUpdates(); return true; case R.id.toggle_inactive: final boolean showInactive = packageListFragment.toggleShowInactive(); item.setTitle(showInactive ? R.string.hide_inactive : R.string.show_inactive); item.setIcon(/* w ww .j a v a2s . co m*/ showInactive ? R.drawable.ic_visibility_off_black_48dp : R.drawable.ic_visibility_black_48dp); return true; case R.id.about: about(); return true; case R.id.settings: final Intent intent = new Intent(this, PreferencesActivity.class); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.example.haber.ui.activity.CallActivity.java
private void showBWselected(final MenuItem item) { if (dialog == null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("").setSingleChoiceItems(callBWs, -1, new DialogInterface.OnClickListener() { @Override//from www. j ava 2 s. c o m public void onClick(DialogInterface dialog, int which) { currentDefaultBW = Integer.parseInt(callBWs[which]); item.setTitle("" + currentDefaultBW); dialog.cancel(); } }); dialog = builder.show(); } else { dialog.show(); } }
From source file:org.mariotaku.twidere.fragment.BaseStatusesListFragment.java
private void openMenu(final View view, final ParcelableStatus status) { if (view == null || status == null) return;//ww w . ja v a2 s .co m final int activated_color = getResources().getColor(R.color.holo_blue_bright); mPopupMenu = PopupMenu.getInstance(getActivity(), view); mPopupMenu.inflate(R.menu.action_status); final boolean click_to_open_menu = mPreferences.getBoolean(PREFERENCE_KEY_CLICK_TO_OPEN_MENU, false); final boolean seprate_retweet_action = mPreferences.getBoolean(PREFERENCE_KEY_SEPRATE_RETWEET_ACTION, false); final Menu menu = mPopupMenu.getMenu(); setMenuForStatus(getActivity(), menu, status); final MenuItem view_status = menu.findItem(MENU_VIEW); if (view_status != null) { view_status.setVisible(click_to_open_menu); } final MenuItem retweet_submenu = menu.findItem(R.id.retweet_submenu); if (retweet_submenu != null) { retweet_submenu.setVisible(!seprate_retweet_action); } final MenuItem direct_quote = menu.findItem(R.id.direct_quote); if (direct_quote != null) { direct_quote.setVisible(seprate_retweet_action); } final MenuItem direct_retweet = menu.findItem(R.id.direct_retweet); if (direct_retweet != null) { final Drawable icon = direct_retweet.getIcon().mutate(); direct_retweet.setVisible(seprate_retweet_action && (!status.is_protected || isMyRetweet(status))); if (isMyRetweet(status)) { icon.setColorFilter(activated_color, PorterDuff.Mode.MULTIPLY); direct_retweet.setTitle(R.string.cancel_retweet); } else { icon.clearColorFilter(); direct_retweet.setTitle(R.string.retweet); } } mPopupMenu.setOnMenuItemClickListener(this); mPopupMenu.show(); }
From source file:com.dldzkj.app.renxing.mainfragment.MyPostFragment0.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings: if (!btnEnable) { return true; }/* w w w . j a v a 2 s.c o m*/ if (datas.size() == 0) { Toast.makeText(this.getActivity(), "?", Toast.LENGTH_SHORT).show(); } else { if (adapter.isDeleteMode()) {//? item.setIcon(R.drawable.ic_delede); item.setTitle(""); bottom.setVisibility(View.GONE); adapter.setDeleteMode(false); } else {// item.setIcon(null); item.setTitle("?"); bottom.setVisibility(View.VISIBLE); adapter.setDeleteMode(true); } adapter.notifyDataSetChanged(); } return true; } return super.onOptionsItemSelected(item); }
From source file:org.libreoffice.ui.LibreOfficeUIActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.view_menu, menu); MenuItem item = menu.findItem(R.id.menu_view_toggle); if (viewMode == GRID_VIEW) { item.setTitle(R.string.list_view); item.setIcon(R.drawable.light_view_as_list); } else {// www .j a v a 2 s . com item.setTitle(R.string.grid_view); item.setIcon(R.drawable.light_view_as_grid); } item = menu.findItem(R.id.menu_sort_size); if (sortMode == FileUtilities.SORT_LARGEST) { item.setTitle(R.string.sort_smallest); } else { item.setTitle(R.string.sort_largest); } item = menu.findItem(R.id.menu_sort_az); if (sortMode == FileUtilities.SORT_AZ) { item.setTitle(R.string.sort_za); } else { item.setTitle(R.string.sort_az); } item = menu.findItem(R.id.menu_sort_modified); if (sortMode == FileUtilities.SORT_NEWEST) { item.setTitle(R.string.sort_oldest); } else { item.setTitle(R.string.sort_newest); } return true; }
From source file:org.digitalcampus.oppia.activity.DownloadMediaActivity.java
@SuppressWarnings("unchecked") @Override//from w ww . jav a2s .co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_download_media); prefs = PreferenceManager.getDefaultSharedPreferences(this); Bundle bundle = this.getIntent().getExtras(); if (bundle != null) { missingMedia = (ArrayList<Media>) bundle.getSerializable(DownloadMediaActivity.TAG); } else { missingMedia = new ArrayList<>(); } mediaSelected = new ArrayList<>(); dmla = new DownloadMediaListAdapter(this, missingMedia); dmla.setOnClickListener(new DownloadMediaListener()); mediaList = (ListView) findViewById(R.id.missing_media_list); mediaList.setAdapter(dmla); mediaList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); mediaList.setMultiChoiceModeListener(new ListView.MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { Log.v(TAG, "Count: " + mediaList.getCheckedItemCount()); if (checked) { mediaSelected.add(missingMedia.get(position)); } else { mediaSelected.remove(missingMedia.get(position)); } int count = mediaSelected.size(); mode.setSubtitle(count == 1 ? count + " item selected" : count + " items selected"); for (Media m : mediaSelected) { if (!m.isDownloading()) { downloadSelected.setText(getString(R.string.missing_media_download_selected)); break; } } } @Override public boolean onCreateActionMode(final ActionMode mode, Menu menu) { onPrepareOptionsMenu(menu); mode.setTitle(R.string.title_download_media); if (missingMediaContainer.getVisibility() != View.VISIBLE) { missingMediaContainer.setVisibility(View.VISIBLE); downloadSelected.setOnClickListener(new OnClickListener() { public void onClick(View v) { DownloadMode downloadMode = downloadSelected.getText().equals( getString(R.string.missing_media_download_selected)) ? DownloadMode.DOWNLOAD_ALL : DownloadMode.STOP_ALL; downloadSelected.setText(downloadSelected.getText() .equals(getString(R.string.missing_media_download_selected)) ? getString(R.string.missing_media_stop_selected) : getString(R.string.missing_media_download_selected)); for (Media m : mediaSelected) { downloadMedia(m, downloadMode); } mode.finish(); } }); unselectAll.setOnClickListener(new OnClickListener() { public void onClick(View view) { mode.finish(); } }); showDownloadMediaMessage(); } dmla.setEnterOnMultiChoiceMode(true); dmla.notifyDataSetChanged(); downloadSelected.setText(getString(R.string.missing_media_stop_selected)); unselectAll.setText(getString(R.string.missing_media_unselect_all)); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menu_sort_by: { if (isSortByCourse) { dmla.sortByFilename(); isSortByCourse = false; item.setTitle(getString(R.string.menu_sort_by_course)); } else { dmla.sortByCourse(); isSortByCourse = true; item.setTitle(getString(R.string.menu_sort_by_filename)); } invalidateOptionsMenu(); return true; } case R.id.menu_select_all: for (int i = 0; i < mediaList.getAdapter().getCount(); i++) { if (!mediaList.isItemChecked(i)) { mediaList.setItemChecked(i, true); } } return true; default: return true; } } @Override public void onDestroyActionMode(ActionMode mode) { mediaSelected.clear(); hideDownloadMediaMessage(); dmla.setEnterOnMultiChoiceMode(false); dmla.notifyDataSetChanged(); } }); missingMediaContainer = this.findViewById(R.id.home_messages); downloadSelected = (TextView) this.findViewById(R.id.download_selected); unselectAll = (TextView) this.findViewById(R.id.unselect_all); downloadViaPCBtn = (Button) this.findViewById(R.id.download_media_via_pc_btn); downloadViaPCBtn.setOnClickListener(new OnClickListener() { public void onClick(View v) { downloadViaPC(); } }); Editor e = prefs.edit(); e.putLong(PrefsActivity.PREF_LAST_MEDIA_SCAN, 0); e.commit(); emptyState = (TextView) findViewById(R.id.empty_state); }
From source file:paulscode.android.mupen64plusae.game.GameActivity.java
private void ReloadAllMenus() { //Reload currently selected speed setting final MenuItem toggleSpeedItem = mGameSidebar.getMenu().findItem(R.id.menuItem_toggle_speed); toggleSpeedItem.setTitle(this.getString(R.string.menuItem_toggleSpeed, NativeExports.emuGetSpeed())); //Reload currently selected slot final MenuItem slotItem = mGameSidebar.getMenu().findItem(R.id.menuItem_set_slot); slotItem.setTitle(this.getString(R.string.menuItem_setSlot, NativeExports.emuGetSlot())); final int resId = NativeExports.emuGetFramelimiter() ? R.string.menuItem_enableFramelimiter : R.string.menuItem_disableFramelimiter; //Reload the menu with the new frame limiter setting final MenuItem frameLimiterItem = mGameSidebar.getMenu().findItem(R.id.menuItem_disable_frame_limiter); frameLimiterItem.setTitle(this.getString(resId)); //Reload player pak settings UpdateControllerMenu(R.id.menuItem_player_one, mGamePrefs.isPlugged1, 1); UpdateControllerMenu(R.id.menuItem_player_two, mGamePrefs.isPlugged2, 2); UpdateControllerMenu(R.id.menuItem_player_three, mGamePrefs.isPlugged3, 3); UpdateControllerMenu(R.id.menuItem_player_four, mGamePrefs.isPlugged4, 4); mGameSidebar.reload();/* w w w . ja v a 2s . c o m*/ }
From source file:com.cerema.cloud2.ui.fragment.OCFileListFragment.java
private void changeGridIcon(Menu menu) { MenuItem menuItem = menu.findItem(R.id.action_switch_view); if (isGridViewPreferred(mFile)) { menuItem.setTitle(getString(R.string.action_switch_list_view)); menuItem.setIcon(R.drawable.ic_view_list); } else {//from w ww.j a v a 2 s. c om menuItem.setTitle(getString(R.string.action_switch_grid_view)); menuItem.setIcon(R.drawable.ic_view_module); } }
From source file:com.zertinteractive.wallpaper.activities.DetailActivity.java
public void setMenuItemFavourite() { if (superCategory == 3) { MenuItem favouriteItem = detailsMenu.findItem(R.id.add_to_favourite); favouriteItem.setTitle("Remove Favourite"); } else {//from w ww . j a va2 s . c o m MenuItem favouriteItem = detailsMenu.findItem(R.id.add_to_favourite); favouriteItem.setTitle("Add to Favourite"); } }