List of usage examples for android.view MenuItem setTitle
public MenuItem setTitle(@StringRes int title);
From source file:org.thbz.hanguldrill.MainActivity.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.main_activity_actions, menu); try {//from ww w .j ava 2 s . com MenuItem configListItem = menu.findItem(R.id.action_configlist); String[] configIds = Settings.ConfigManager.getAllConfigIds(this); if (configListItem.hasSubMenu() && configIds.length > 0) { SubMenu configMenu = configListItem.getSubMenu(); if (configMenu == null) { if (BuildConfig.DEBUG) Log.d(TAG, "configMenu = null"); } else { // On ajoute une entre pour chacune des configurations existantes for (int i = 0; i < configIds.length; i++) { String configId = configIds[i]; Settings.Configuration config = Settings.ConfigManager.getConfigFromId(this, configId); String name = config.getName(this); configMenu.add(Menu.NONE, START_MENUITEM_ID + i, i, name); } } // Set configMenu title try { Settings.Configuration lastSelectedConfig = Settings.ConfigManager.getLastSelectedConfig(this); if (lastSelectedConfig != null) { String configName = lastSelectedConfig.getName(this); if (configName != null) { if (configName.length() > 15) configName = configName.substring(0, 13) + "\u2026"; configListItem.setTitle(configName); } } } catch (ClassCastException exc) { toastError("Exception : " + exc.getMessage()); } } } catch (InternalException exc) { if (BuildConfig.DEBUG) if (BuildConfig.DEBUG) Log.e(TAG, "Erreur interne", exc); } return super.onCreateOptionsMenu(menu); }
From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java
@Override public void onClick(final View view) { switch (view.getId()) { case R.id.follow: { if (mUser != null && mAccountId != mUser.getId()) { mFollowProgress.setVisibility(View.VISIBLE); mFollowButton.setVisibility(View.GONE); if (mFriendship.isSourceFollowingTarget()) { mService.destroyFriendship(mAccountId, mUser.getId()); } else { mService.createFriendship(mAccountId, mUser.getId()); }/*from ww w .j av a2 s .c om*/ } break; } case R.id.retry: { reloadUserInfo(); break; } case R.id.name_container: { if (mUser != null) { } break; } case R.id.profile_image_container: { final String profile_image_url_string = getOriginalTwitterProfileImage( parseString(mUser.getProfileImageURL())); if (profile_image_url_string == null) return; final Uri uri = Uri.parse(profile_image_url_string); openImage(getActivity(), uri, false); break; } case R.id.tweets_container: { if (mUser == null) return; openUserTimeline(getActivity(), mAccountId, mUser.getId(), mUser.getScreenName()); break; } case R.id.followers_container: { if (mUser == null) return; openUserFollowers(getActivity(), mAccountId, mUser.getId(), mUser.getScreenName()); break; } case R.id.friends_container: { if (mUser == null) return; openUserFriends(getActivity(), mAccountId, mUser.getId(), mUser.getScreenName()); break; } case R.id.more_options: { if (mUser == null || mFriendship == null) return; if (!isMyActivatedAccount(getActivity(), mUser.getId())) { mPopupMenu = PopupMenu.getInstance(getActivity(), view); mPopupMenu.inflate(R.menu.action_user_profile); final Menu menu = mPopupMenu.getMenu(); final MenuItem blockItem = menu.findItem(MENU_BLOCK); final MenuItem trackItem = menu.findItem(MENU_TRACKING); if (blockItem != null) { final Drawable blockIcon = blockItem.getIcon(); if (mFriendship.isSourceBlockingTarget()) { blockItem.setTitle(R.string.unblock); blockIcon.mutate().setColorFilter(getResources().getColor(R.color.holo_blue_bright), PorterDuff.Mode.MULTIPLY); } else { blockItem.setTitle(R.string.block); blockIcon.clearColorFilter(); } } if (trackItem != null) { if (mPreferences.getBoolean(com.dwdesign.tweetings.Constants.PREFERENCE_KEY_PUSH_NOTIFICATIONS, false) == false) { trackItem.setVisible(false); } else { if (tracking == true) { trackItem.setTitle(R.string.untrack_user); } else { trackItem.setTitle(R.string.track_user); } } } final MenuItem sendDirectMessageItem = menu.findItem(MENU_SEND_DIRECT_MESSAGE); if (sendDirectMessageItem != null) { sendDirectMessageItem.setVisible(mFriendship.isTargetFollowingSource()); } final MenuItem wantRetweetsItem = menu.findItem(MENU_WANT_RETWEETS); if (mFriendship.wantRetweets() == true) { wantRetweetsItem.setTitle(R.string.disable_retweet); } else { wantRetweetsItem.setTitle(R.string.enable_retweet); } mPopupMenu.setOnMenuItemClickListener(this); mPopupMenu.show(); } break; } } }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
/** * Initializes the navigation drawer, when the app is started. */// w w w . j a va 2 s . c o m @SuppressWarnings("deprecation") private void setupNavigationDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { }; // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); NavigationView mDrawer = (NavigationView) findViewById(R.id.left_drawer); setupDrawerContent(mDrawer); // Set the item text for the debug view in the naviation drawer: if (mDrawer == null) return; Menu menu = mDrawer.getMenu(); if (menu == null) return; MenuItem item = menu.findItem(R.id.debug_view_item); if (item == null) return; if (mIsDebugViewEnabled) item.setTitle(R.string.hide_debug_view_text); else item.setTitle(R.string.show_debug_view_text); }
From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java
@Override public boolean configureOptionsMenu(MenuInflater inflater, Menu menu) { if (inflater != null && mContentHandle != null && (mContentHandle.getStatusesType() == StatusesType.USER_TIMELINE || mContentHandle.getStatusesType() == StatusesType.USER_HOME_TIMELINE || mContentHandle.getStatusesType() == StatusesType.USER_LIST_TIMELINE)) { if (getBaseLaneActivity() instanceof HomeActivity) { inflater.inflate(R.menu.home_tweet_feed_action_bar, menu); } else {/* w ww. java2 s.c o m*/ inflater.inflate(R.menu.tweet_feed_action_bar, menu); } for (int i = 0; i < menu.size(); i++) { MenuItem menuItem = menu.getItem(i); if (menuItem.getItemId() == R.id.action_feed_filter) { SubMenu subMenu = menuItem.getSubMenu(); if (subMenu != null) { SocialNetConstant.Type socialNetType = getApp().getCurrentAccount().getSocialNetType(); int subMenuSize = subMenu.size(); for (int j = 0; j < subMenuSize; j++) { MenuItem subMenuItem = subMenu.getItem(j); int i1 = subMenuItem.getItemId(); if (i1 == R.id.action_replies_visibility) { subMenuItem .setTitle(getString(getBaseLaneActivity().mStatusesFilter.getShowReplies() ? R.string.action_hide_replies : R.string.action_show_replies)); } else if (i1 == R.id.action_retweets_visibility) { subMenuItem .setTitle(getString(getBaseLaneActivity().mStatusesFilter.getShowRetweets() ? socialNetType == SocialNetConstant.Type.Twitter ? R.string.action_hide_retweets : R.string.action_hide_retweets_adn : socialNetType == SocialNetConstant.Type.Twitter ? R.string.action_show_retweets : R.string.action_show_retweets_adn)); } else { } } } } } return true; } return false; }
From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int i = item.getItemId(); if (i == R.id.action_replies_visibility) { getBaseLaneActivity().mStatusesFilter .setShowReplies(!getBaseLaneActivity().mStatusesFilter.getShowReplies()); item.setTitle( getString(getBaseLaneActivity().mStatusesFilter.getShowReplies() ? R.string.action_hide_replies : R.string.action_show_replies)); mTweetFeedListAdapter.notifyDataSetChanged(); return false; } else if (i == R.id.action_retweets_visibility) { getBaseLaneActivity().mStatusesFilter .setShowRetweets(!getBaseLaneActivity().mStatusesFilter.getShowRetweets()); item.setTitle(getString(//from www.j a v a 2s. c om getBaseLaneActivity().mStatusesFilter.getShowRetweets() ? R.string.action_hide_retweets : R.string.action_show_retweets)); mTweetFeedListAdapter.notifyDataSetChanged(); return false; } return false; }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
private void setMenu() { final Menu menu = mMenuBar.getMenu(); final int activated_color = getResources().getColor(R.color.holo_blue_bright); final MenuItem itemAddImage = menu.findItem(MENU_ADD_IMAGE); final MenuItem itemLibrary = menu.findItem(MENU_LIBRARY_MENU); final Drawable iconAddImage = itemAddImage.getIcon().mutate(); final Drawable iconLibrary = itemLibrary.getIcon().mutate(); boolean menuSelected = false; if (mIsImageAttached && !mIsPhotoAttached) { iconAddImage.setColorFilter(activated_color, Mode.MULTIPLY); itemAddImage.setTitle(R.string.remove_image); menuSelected = true;/* w ww .j a va 2s .com*/ } else { iconAddImage.clearColorFilter(); itemAddImage.setTitle(R.string.add_image); } final MenuItem itemTakePhoto = menu.findItem(MENU_TAKE_PHOTO); final Drawable iconTakePhoto = itemTakePhoto.getIcon().mutate(); if (!mIsImageAttached && mIsPhotoAttached) { iconTakePhoto.setColorFilter(activated_color, Mode.MULTIPLY); itemTakePhoto.setTitle(R.string.remove_photo); menuSelected = true; } else { iconTakePhoto.clearColorFilter(); itemTakePhoto.setTitle(R.string.take_photo); } if (menuSelected == true) { iconLibrary.setColorFilter(activated_color, Mode.MULTIPLY); } else { iconLibrary.clearColorFilter(); } final MenuItem itemAttachLocation = menu.findItem(MENU_ADD_LOCATION); final Drawable iconAttachLocation = itemAttachLocation.getIcon().mutate(); final boolean attach_location = mPreferences.getBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false); if (attach_location && getLocation()) { iconAttachLocation.setColorFilter(activated_color, Mode.MULTIPLY); itemAttachLocation.setTitle(R.string.remove_location); } else { mPreferences.edit().putBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false).commit(); iconAttachLocation.clearColorFilter(); itemAttachLocation.setTitle(R.string.add_location); } final MenuItem itemMore = menu.findItem(R.id.more_submenu); boolean moreHighlighted = false; if (itemMore != null) { final MenuItem itemDrafts = menu.findItem(R.id.drafts); final MenuItem itemToggleSensitive = menu.findItem(MENU_TOGGLE_SENSITIVE); if (itemMore != null) { if (itemDrafts != null) { final Cursor drafts_cur = getContentResolver().query(Drafts.CONTENT_URI, new String[0], null, null, null); final Drawable iconMore = itemMore.getIcon().mutate(); final Drawable iconDrafts = itemDrafts.getIcon().mutate(); if (drafts_cur.getCount() > 0) { moreHighlighted = true; iconDrafts.setColorFilter(activated_color, Mode.MULTIPLY); } else { iconDrafts.clearColorFilter(); } drafts_cur.close(); } if (itemToggleSensitive != null) { final boolean has_media = (mIsImageAttached || mIsPhotoAttached) && mImageUri != null; if (has_media && isNullOrEmpty(mUploadProvider)) { itemToggleSensitive.setVisible(true); } else { itemToggleSensitive.setVisible(false); } if (has_media && isNullOrEmpty(mUploadProvider)) { final Drawable iconToggleSensitive = itemToggleSensitive.getIcon().mutate(); if (mIsPossiblySensitive) { moreHighlighted = true; iconToggleSensitive.setColorFilter(activated_color, Mode.MULTIPLY); } else { iconToggleSensitive.clearColorFilter(); } } } } } if (mScheduleDate != null) { final MenuItem itemSchedule = menu.findItem(R.id.schedule_tweet); final Drawable iconSchedule = itemSchedule.getIcon().mutate(); iconSchedule.setColorFilter(activated_color, Mode.MULTIPLY); moreHighlighted = true; itemSchedule.setTitle(getString(R.string.schedule_clear)); } else { final MenuItem itemSchedule = menu.findItem(R.id.schedule_tweet); final Drawable iconSchedule = itemSchedule.getIcon().mutate(); iconSchedule.clearColorFilter(); itemSchedule.setTitle(getString(R.string.schedule_tweet)); } final String consumer_key = mPreferences.getString(PREFERENCE_KEY_CONSUMER_KEY, null); final String consumer_secret = mPreferences.getString(PREFERENCE_KEY_CONSUMER_SECRET, null); if (!isNullOrEmpty(consumer_key) && !isNullOrEmpty(consumer_secret)) { final MenuItem itemSchedule = menu.findItem(R.id.schedule_tweet); itemSchedule.setVisible(false); } final MenuItem bufferItem = menu.findItem(MENU_ADD_TO_BUFFER); if (bufferItem != null) { final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null); final Drawable iconBuffer = bufferItem.getIcon().mutate(); if (buffer_authorised != null && !buffer_authorised.equals("")) { bufferItem.setVisible(true); if (mIsBuffer) { iconBuffer.setColorFilter(activated_color, Mode.MULTIPLY); moreHighlighted = true; } else { iconBuffer.clearColorFilter(); } } else { bufferItem.setVisible(false); mIsBuffer = false; } } if (itemMore != null) { final Drawable iconMore = itemMore.getIcon().mutate(); if (moreHighlighted == true) { iconMore.setColorFilter(activated_color, Mode.MULTIPLY); } else { iconMore.clearColorFilter(); } } mMenuBar.invalidate(); invalidateSupportOptionsMenu(); }
From source file:cgeo.geocaching.CacheListActivity.java
private void setMenuItemLabel(final Menu menu, final int menuId, @StringRes final int resIdSelection, @StringRes final int resId) { final MenuItem menuItem = menu.findItem(menuId); if (menuItem == null) { return;//from w w w .j a v a 2 s . co m } final boolean hasSelection = adapter != null && adapter.getCheckedCount() > 0; if (hasSelection) { menuItem.setTitle(res.getString(resIdSelection) + " (" + adapter.getCheckedCount() + ")"); } else { menuItem.setTitle(res.getString(resId)); } }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
private void stopScan() { if (mScanning) { runOnUiThread(new Runnable() { @Override/* w ww . j a va2 s .c o m*/ public void run() { if (mScanType == ScanType.CLASSIC_SCAN) { mBluetoothAdapter.cancelDiscovery(); } else { Toast.makeText(HciDebuggerActivity.this, getResources().getString(R.string.toast_scan_stop), Toast.LENGTH_SHORT).show(); mBluetoothAdapter.stopLeScan(scanCallback); } mScanning = false; MenuItem item; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { item = nvDrawer.getMenu().findItem(R.id.scan_btn_nv); } else { item = toolbar.getMenu().findItem(R.id.scan_btn); } if (item != null) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { item.setIcon(R.drawable.ic_looks); } else { item.setIcon(R.drawable.ic_action_scanning); } item.setTitle(getResources().getString(R.string.menu_item_title_start_scan)); } //Toast.makeText(HciDebuggerActivity.this, getResources().getString(R.string.toast_scan_stop), Toast.LENGTH_SHORT).show(); } }); } else { Log.v(TAG, "not scanning"); } }
From source file:com.ezac.gliderlogs.FlightOverviewActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.listmenu, menu); this.menu = menu; // adjust value in menu button to value in use MenuItem MenuItem_dur = menu.findItem(R.id.action_45min); MenuItem_dur.setTitle("" + appPRE + " Min"); // adjust visibility of some menu tabs String v[] = appFLG.split(";"); //Log.d(TAG,"p1 " + isInit + " p2 "+ Boolean.parseBoolean(v[1])); menu.findItem(R.id.action_db_start)/*from www .j a v a2 s . c om*/ .setVisible(((isInit == true) && Boolean.parseBoolean(v[1])) ? false : true); menu.findItem(R.id.action_ezac).setVisible(Boolean.parseBoolean(v[2])); menu.findItem(R.id.action_meteo_group).setVisible(Boolean.parseBoolean(v[3])); menu.findItem(R.id.action_ntm_nld).setVisible(Boolean.parseBoolean(v[4])); menu.findItem(R.id.action_ntm_blx).setVisible(Boolean.parseBoolean(v[4])); menu.findItem(R.id.action_ogn_flarm).setVisible(Boolean.parseBoolean(v[5])); menu.findItem(R.id.action_adsb).setVisible(Boolean.parseBoolean(v[6])); menu.findItem(R.id.action_adsb_lcl).setVisible(Boolean.parseBoolean(v[7])); // adjust value in menu button to current date MenuItem MenuItem_date = menu.findItem(R.id.action_date); String s[] = ToDay.split("-"); MenuItem_date.setTitle(s[0] + " " + month_list[Integer.parseInt(s[1]) - 1]); return true; }