List of usage examples for android.view MenuItem setTitle
public MenuItem setTitle(@StringRes int title);
From source file:com.google.android.gcm.demo.ui.MainMenu.java
public boolean onOverflowMenuItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.toggle_logs: { CharSequence showLogs = mActivity.getString(R.string.show_logs); if (showLogs.equals(item.getTitle())) { mActivity.toggleLogsView(true); item.setTitle(R.string.hide_logs); item.setIcon(R.drawable.visibility_off_white); } else {//from w w w .j a v a2s .co m mActivity.toggleLogsView(false); item.setTitle(R.string.show_logs); item.setIcon(R.drawable.visibility_white); } return true; } case R.id.clear_logs: { (new Logger(mActivity)).clearLogs(); return true; } default: return false; } }
From source file:org.catrobat.catroid.ui.ScratchConverterActivity.java
private void handleShowDetails(boolean showDetails, MenuItem item) { searchProjectsListFragment.setShowDetails(showDetails); item.setTitle(showDetails ? R.string.hide_details : R.string.show_details); }
From source file:org.cirdles.chroni.ImportFilesActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // changes the Exit item to say "Back" instead MenuItem exitItem = menu.findItem(R.id.exitMenu); exitItem.setTitle("Back"); return true;/*from w ww . j ava2 s . c om*/ }
From source file:fr.simon.marquis.preferencesmanager.ui.AppListActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { boolean show = Utils.isShowSystemApps(this); MenuItem showItem = menu.findItem(R.id.show_system_apps); if (showItem != null) { showItem.setTitle(show ? R.string.hide_system_apps : R.string.show_system_apps); showItem.setIcon(show ? R.drawable.ic_action_show : R.drawable.ic_action_hide); }/*from w w w . j a v a2 s . c o m*/ MenuItem themeItem = menu.findItem(R.id.switch_theme); if (themeItem != null) { themeItem.setTitle(App.theme.title); } return super.onPrepareOptionsMenu(menu); }
From source file:org.runnerup.view.AccountListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_tab_format: mTabFormat = !mTabFormat;/*from w w w.j a va 2 s . c om*/ item.setTitle(getString(R.string.Icon_list)); getSupportLoaderManager().restartLoader(0, null, this); break; } return true; }
From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { Log.v(TAG, "onPrepareOptionsMenu"); super.onPrepareOptionsMenu(menu); MenuItem fav = menu.findItem(R.id.action_favorite); if (fav == null) { Log.v(TAG, "Menu not inflated yet?"); return;/*w w w. j av a 2 s.c o m*/ } if (mIsFavorite) { fav.setTitle(R.string.action_favorite_activated); fav.setIcon(R.drawable.ic_action_favorite_activated); } else { fav.setTitle(R.string.action_favorite_normal); fav.setIcon(R.drawable.ic_action_favorite_normal); } }
From source file:com.cullaboration.userhookdemo.MainActivity.java
public void loadStaticPages() { UserHook.fetchPageNames(new UHOperation.UHArrayListener<UHPage>() { @Override// w w w.j a v a 2s . c o m public void onSuccess(List<UHPage> items) { SubMenu staticMenu = navigationView.getMenu().addSubMenu("Static Pages"); for (UHPage page : items) { // add page to menu staticMenu.add(page.getName()); // store the page item for use in the click listener staticPages.put(page.getName(), page); } // hack to refresh menu MenuItem mi = navigationView.getMenu().getItem(navigationView.getMenu().size() - 1); mi.setTitle(mi.getTitle()); } }); }
From source file:de.tap.easy_xkcd.fragments.overview.OverviewRecyclerBaseFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_favorite: if (prefHelper.overviewFav()) { item.setIcon(R.drawable.ic_favorite_outline); item.setTitle(R.string.nv_favorites); } else {/* ww w .ja v a 2 s .c o m*/ item.setIcon(R.drawable.ic_action_favorite); item.setTitle(R.string.action_overview); } prefHelper.setOverviewFav(!prefHelper.overviewFav()); getActivity().invalidateOptionsMenu(); setupAdapter(); break; case R.id.action_boomark: super.goToComic(bookmark - 1); break; case R.id.action_unread: databaseManager.setComicsUnread(); setupAdapter(); break; case R.id.action_hide_read: item.setChecked(!item.isChecked()); prefHelper.setHideRead(item.isChecked()); setupAdapter(); break; } return super.onOptionsItemSelected(item); }
From source file:com.example.joeroger.homework2.activity.WeatherActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.toggle_favorite); item.setTitle(isSelectedFavorite ? R.string.remove_favorite : R.string.add_favorite); return super.onPrepareOptionsMenu(menu); }
From source file:ansteph.com.beecabfordrivers.view.CabResponder.JobsBoard.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_jobs_board, menu); MenuItem loggedUser = menu.findItem(R.id.action_loggedUser); if (mGlobalRetainer.get_grDriver().getName() != null) { loggedUser.setTitle(mGlobalRetainer.get_grDriver().getName()); }/*from www . j a va 2s . c o m*/ return true; }