List of usage examples for android.view MenuItem setTitle
public MenuItem setTitle(@StringRes int title);
From source file:com.app.uafeed.fragment.EntryFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mEntriesIds != null) { Activity activity = getActivity(); switch (item.getItemId()) { case R.id.menu_star: { mFavorite = !mFavorite;//w ww . j av a 2 s . co m if (mFavorite) { item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important); } else { item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important); } final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentValues values = new ContentValues(); values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0); ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, values, null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }.start(); break; } case R.id.menu_share: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String link = cursor.getString(mLinkPos); if (link != null) { String title = cursor.getString(mTitlePos); startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_SUBJECT, title) .putExtra(Intent.EXTRA_TEXT, link).setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share))); } break; } case R.id.menu_full_screen: { toggleFullScreen(); break; } case R.id.menu_copy_clipboard: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String link = cursor.getString(mLinkPos); ClipboardManager clipboard = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", link); clipboard.setPrimaryClip(clip); Toast.makeText(activity, R.string.copied_clipboard, Toast.LENGTH_SHORT).show(); break; } case R.id.menu_mark_as_unread: { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, FeedData.getUnreadContentValues(), null, null); } }.start(); activity.finish(); break; } } } return true; }
From source file:net.fred.feedex.activity.HomeActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from ww w . j av a 2s . c om*/ switch (item.getItemId()) { case R.id.menu_hide_read_main: if (!PrefUtils.getBoolean(PrefUtils.SHOW_READ, true)) { PrefUtils.putBoolean(PrefUtils.SHOW_READ, true); item.setTitle(R.string.context_menu_hide_read).setIcon(R.drawable.hide_reads); } else { PrefUtils.putBoolean(PrefUtils.SHOW_READ, false); item.setTitle(R.string.context_menu_show_read).setIcon(R.drawable.view_reads); } return true; case R.id.menu_edit_main: startActivity(new Intent(this, EditFeedsListActivity.class)); return true; case R.id.menu_refresh_main: if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) { MainApplication.getContext() .startService(new Intent(MainApplication.getContext(), FetcherService.class) .setAction(FetcherService.ACTION_REFRESH_FEEDS)); } return true; case R.id.menu_settings_main: startActivity(new Intent(this, GeneralPrefsActivity.class)); return true; default: return super.onOptionsItemSelected(item); } }
From source file:tv.acfun.a63.ArticleActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (AcApp.getViewMode() != Constants.MODE_COMMIC && !isWebMode) { getMenuInflater().inflate(R.menu.article_options_menu, menu); MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar); if (ActionBarUtil.hasSB()) { MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_NEVER); }/*from ww w . j av a 2s .c o m*/ ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(actionItem); actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); actionProvider.setShareIntent(createShareIntent()); if (isFaved) { MenuItem fav = menu.findItem(R.id.menu_item_fav_action); fav.setIcon(R.drawable.rating_favorite_p); fav.setTitle("??"); } MenuItem item = menu.add(0, android.R.id.button1, 0, R.string.font_size) .setIcon(R.drawable.ic_text_size); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); } return super.onCreateOptionsMenu(menu); }
From source file:com.boko.vimusic.ui.activities.ProfileActivity.java
/** * {@inheritDoc}/*from www . j a v a 2s .com*/ */ @Override public boolean onPrepareOptionsMenu(final Menu menu) { // Theme the add to home screen icon mResources.setAddToHomeScreenIcon(menu); // Set the shuffle all title to "play all" if a playlist. final MenuItem shuffle = menu.findItem(R.id.menu_shuffle); String title = null; if (isFavorites() || isLastAdded() || isPlaylist()) { title = getString(R.string.menu_play_all); } else { title = getString(R.string.menu_shuffle); } shuffle.setTitle(title); return super.onPrepareOptionsMenu(menu); }
From source file:com.sj.android.appusage.activities.UsageListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { // TODO Auto-generated method stub MenuItem filterMenu = (MenuItem) menu.findItem(R.id.filter_menu); if (UsageSharedPrefernceHelper.isFilterMode(mActivity)) { filterMenu.setIcon(R.drawable.ic_select_all_white_24dp); filterMenu.setTitle(R.string.string_all); } else {/* www . ja va 2 s . com*/ filterMenu.setIcon(R.drawable.ic_filter_list_white_24dp); filterMenu.setTitle(R.string.string_filter); } MenuItem menuItemSortBy = menu.findItem(R.id.action_sort_by); MenuItem menuItemFilter = (MenuItem) menu.findItem(R.id.filter_menu); if (mViewPager != null) { switch (mViewPager.getCurrentItem()) { case 0: if (mAppDataListAdapter != null && !mAppDataListAdapter.isEmpty()) { menuItemFilter.setVisible(true); } break; case 1: menuItemSortBy.setVisible(false); menuItemFilter.setVisible(false); break; default: break; } } super.onPrepareOptionsMenu(menu); }
From source file:com.tct.mail.ui.ActionBarController.java
public void setConversationModeOptions(Menu menu) { if (mCurrentConversation == null) { return;//from w w w . ja v a2s .c o m } final boolean showMarkImportant = !mCurrentConversation.isImportant(); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.mark_important, showMarkImportant && mAccount.supportsCapability(UIProvider.AccountCapabilities.MARK_IMPORTANT)); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.mark_not_important, !showMarkImportant && mAccount.supportsCapability(UIProvider.AccountCapabilities.MARK_IMPORTANT)); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-S // Trashbox need not show mark star and mark unstar final boolean isTrashbox = mFolder != null && mFolder.isType(FolderType.TRASH); final boolean showMarkStar = !mCurrentConversation.starred; LogUtils.i(LOG_TAG, "in ABC.setConversationModeOptions() conversation [ %s, %s ]", mCurrentConversation.id, mCurrentConversation.starred); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.mark_star, isTrashbox ? false : showMarkStar); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.mark_unstar, isTrashbox ? false : !showMarkStar); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-E //[BUGFIX]-Add-BEGIN by CDTS.chao-zhang,08/19/2015,PR 1070880 //NOTE: avoid NPE happen during monkey test. final boolean isOutbox = mFolder != null && mFolder.isType(FolderType.OUTBOX); //[BUGFIX]-Add-BEGIN by CDTS.chaozhang,08/19/2015,PR 1070880 final boolean showDiscardOutbox = mFolder != null && isOutbox && mCurrentConversation.sendingState == UIProvider.ConversationSendingState.SEND_ERROR; Utils.setMenuItemVisibilityAndAvailability(menu, R.id.discard_outbox, showDiscardOutbox); final boolean showDelete = !isOutbox && mFolder != null && mFolder.supportsCapability(UIProvider.FolderCapabilities.DELETE); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.delete, showDelete); // We only want to show the discard drafts menu item if we are not showing the delete menu // item, and the current folder is a draft folder and the account supports discarding // drafts for a conversation final boolean showDiscardDrafts = !showDelete && mFolder != null && mFolder.isDraft() && mAccount.supportsCapability(AccountCapabilities.DISCARD_CONVERSATION_DRAFTS); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.discard_drafts, showDiscardDrafts); final boolean archiveVisible = mAccount.supportsCapability(AccountCapabilities.ARCHIVE) && mFolder != null && mFolder.supportsCapability(FolderCapabilities.ARCHIVE) && !mFolder.isTrash(); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.archive, archiveVisible); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.remove_folder, !archiveVisible && mFolder != null && mFolder.supportsCapability(FolderCapabilities.CAN_ACCEPT_MOVED_MESSAGES) && !mFolder.isProviderFolder() && mAccount.supportsCapability(AccountCapabilities.ARCHIVE)); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.move_to, mFolder != null && mFolder.supportsCapability(FolderCapabilities.ALLOWS_REMOVE_CONVERSATION)); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.move_to_inbox, mFolder != null && mFolder.supportsCapability(FolderCapabilities.ALLOWS_MOVE_TO_INBOX)); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.change_folders, mAccount.supportsCapability(UIProvider.AccountCapabilities.MULTIPLE_FOLDERS_PER_CONV)); final MenuItem removeFolder = menu.findItem(R.id.remove_folder); if (mFolder != null && removeFolder != null) { removeFolder .setTitle(mActivity.getApplicationContext().getString(R.string.remove_folder, mFolder.name)); } Utils.setMenuItemVisibilityAndAvailability(menu, R.id.report_spam, mAccount.supportsCapability(AccountCapabilities.REPORT_SPAM) && mFolder != null && mFolder.supportsCapability(FolderCapabilities.REPORT_SPAM) && !mCurrentConversation.spam); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.mark_not_spam, mAccount.supportsCapability(AccountCapabilities.REPORT_SPAM) && mFolder != null && mFolder.supportsCapability(FolderCapabilities.MARK_NOT_SPAM) && mCurrentConversation.spam); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.report_phishing, mAccount.supportsCapability(AccountCapabilities.REPORT_PHISHING) && mFolder != null && mFolder.supportsCapability(FolderCapabilities.REPORT_PHISHING) && !mCurrentConversation.phishing); Utils.setMenuItemVisibilityAndAvailability(menu, R.id.mute, mAccount.supportsCapability(AccountCapabilities.MUTE) && mFolder != null && mFolder.supportsCapability(FolderCapabilities.DESTRUCTIVE_MUTE) && !mCurrentConversation.muted); }
From source file:com.viktorrudometkin.burramys.fragment.EntryFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mEntriesIds != null) { Activity activity = getActivity(); switch (item.getItemId()) { case R.id.menu_star: { mFavorite = !mFavorite;/*from w ww . ja va2s. c o m*/ if (mFavorite) { item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important); } else { item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important); } final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentValues values = new ContentValues(); values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0); ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, values, null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }.start(); break; } case R.id.menu_share: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); if (cursor != null) { String link = cursor.getString(mLinkPos); if (link != null) { String title = cursor.getString(mTitlePos); startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_SUBJECT, title) .putExtra(Intent.EXTRA_TEXT, link).setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share))); } } break; } case R.id.menu_full_screen: { setImmersiveFullScreen(true); break; } case R.id.menu_copy_clipboard: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String link = cursor.getString(mLinkPos); ClipboardManager clipboard = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", link); clipboard.setPrimaryClip(clip); UiUtils.showMessage(getActivity(), R.string.copied_clipboard); break; } case R.id.menu_mark_as_unread: { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, FeedData.getUnreadContentValues(), null, null); } }.start(); activity.finish(); break; } } } return true; }
From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE, getString(R.string.order_call_taxi_page_title)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString); if (isShowOneKey) item.setVisible(true);//ww w . j ava 2 s . c o m else item.setVisible(false); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.keepassdroid.EntryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_donate: try {/* w w w.j a v a 2 s .c o m*/ Util.gotoUrl(this, R.string.donate_url); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.error_failed_to_launch_link, Toast.LENGTH_LONG).show(); return false; } return true; case R.id.menu_toggle_pass: if (mShowPassword) { item.setTitle(R.string.menu_showpass); mShowPassword = false; } else { item.setTitle(R.string.menu_hide_password); mShowPassword = true; } setPasswordStyle(); return true; case R.id.menu_goto_url: String url; url = mEntry.getUrl(); // Default http:// if no protocol specified if (!url.contains("://")) { url = "http://" + url; } try { Util.gotoUrl(this, url); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.no_url_handler, Toast.LENGTH_LONG).show(); } return true; case R.id.menu_copy_user: timeoutCopyToClipboard(mEntry.getUsername(true, App.getDB().pm)); return true; case R.id.menu_copy_pass: timeoutCopyToClipboard(new String(mEntry.getPassword(true, App.getDB().pm))); return true; case R.id.menu_lock: App.setShutdown(); setResult(KeePass.EXIT_LOCK); finish(); return true; } return super.onOptionsItemSelected(item); }
From source file:org.cgnet.swara.fragment.EntryFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mEntriesIds != null) { Activity activity = getActivity(); switch (item.getItemId()) { case R.id.menu_star: { mFavorite = !mFavorite;//from ww w. j a v a2s . co m if (mFavorite) { item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important); } else { item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important); } final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentValues values = new ContentValues(); values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0); ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, values, null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }.start(); break; } case R.id.menu_share: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String enclose = cursor.getString(mEnclosurePos); String temp = enclose.split("http://cgnetswara.org//audio/")[1]; String audio_recording = temp.split("\\[")[0]; // Creates a folder for the app's recordings String path_audio = Environment.getExternalStorageDirectory().getAbsolutePath(); path_audio += "/CGNet_Swara"; audio_recording = path_audio + "/" + audio_recording; File child = new File(audio_recording); if (child.exists()) { Log.e("enclose", "INSDIE" + audio_recording); t.send(new HitBuilders.EventBuilder().setCategory("Audio file shared.") .setLabel(audio_recording).build()); startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND).setType("audio/*") .putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + audio_recording)) .setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share))); } break; } } } return true; }