Java Code Examples for android.view.MenuItem#getTitle()
The following examples show how to use
android.view.MenuItem#getTitle() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ans-android-sdk File: ViewClickProbe.java License: GNU General Public License v3.0 | 5 votes |
@Override public void trackMenuItem(Object object, MenuItem menuItem, boolean hasTrackClickAnn,long currentTime) { try { if (isTrackClickSwitchClose()) { return; } Object pageObj = null; if (!AllegroUtils.isPage(object)) { pageObj = AllegroUtils.getPageObjFromView(null); } if (!checkTrackClickEnable(pageObj, menuItem, hasTrackClickAnn)) { return; } Map<String, Object> elementInfo = new HashMap<>(); elementInfo.put(Constants.ELEMENT_TYPE, "MenuItem"); CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title)) { elementInfo.put(Constants.ELEMENT_CONTENT, title); } String idName = AllegroUtils.getIdResourceName(menuItem.getItemId()); if (!TextUtils.isEmpty(idName)) { elementInfo.put(Constants.ELEMENT_ID, idName); } autoTrackClick(pageObj, elementInfo, hasTrackClickAnn,currentTime); } catch (Throwable ignore) { ExceptionUtil.exceptionThrow(ignore); } }
Example 2
Source Project: tracker-control-android File: ActivityMain.java License: GNU General Public License v3.0 | 5 votes |
private void markPro(MenuItem menu, String sku) { if (sku == null || !IAB.isPurchased(sku, this)) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean dark = prefs.getBoolean("dark_theme", false); SpannableStringBuilder ssb = new SpannableStringBuilder(" " + menu.getTitle()); ssb.setSpan(new ImageSpan(this, dark ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); menu.setTitle(ssb); } }
Example 3
Source Project: tracker-control-android File: AdapterRule.java License: GNU General Public License v3.0 | 5 votes |
private void markPro(Context context, MenuItem menu, String sku) { if (sku == null || !IAB.isPurchased(sku, context)) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean dark = prefs.getBoolean("dark_theme", false); SpannableStringBuilder ssb = new SpannableStringBuilder(" " + menu.getTitle()); ssb.setSpan(new ImageSpan(context, dark ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); menu.setTitle(ssb); } }
Example 4
Source Project: NetGuard File: AdapterRule.java License: GNU General Public License v3.0 | 5 votes |
private void markPro(Context context, MenuItem menu, String sku) { if (sku == null || !IAB.isPurchased(sku, context)) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean dark = prefs.getBoolean("dark_theme", false); SpannableStringBuilder ssb = new SpannableStringBuilder(" " + menu.getTitle()); ssb.setSpan(new ImageSpan(context, dark ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); menu.setTitle(ssb); } }
Example 5
Source Project: FireFiles File: FabSpeedDial.java License: Apache License 2.0 | 5 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (Utils.hasLollipop()) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
Example 6
Source Project: Carbon File: NavigationView.java License: Apache License 2.0 | 5 votes |
public Item(MenuItem item) { id = item.getItemId(); icon = item.getIcon(); tint = MenuItemCompat.getIconTintList(item); groupId = item.getGroupId(); title = item.getTitle(); }
Example 7
Source Project: Camera-Roll-Android-App File: ItemActivity.java License: Apache License 2.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (theme.isBaseLight()) { int black = ContextCompat.getColor(this, R.color.black); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); SpannableString s = new SpannableString(item.getTitle()); s.setSpan(new ForegroundColorSpan(black), 0, s.length(), 0); item.setTitle(s); } } return super.onPrepareOptionsMenu(menu); }
Example 8
Source Project: science-journal File: MainActivity.java License: Apache License 2.0 | 5 votes |
private CharSequence getTitleToRestore(MenuItem menuItem) { if (menuItem.getItemId() == R.id.navigation_item_experiments) { return getResources().getString(R.string.app_name); } else { return menuItem.getTitle(); } }
Example 9
Source Project: RedReader File: CommentListingFragment.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getTitle() != null && item.getTitle().equals(getActivity().getString(R.string.action_reply))) { onParentReply(); return true; } return false; }
Example 10
Source Project: material-components-android File: ThemePreferencesManager.java License: Apache License 2.0 | 5 votes |
@SuppressWarnings("RestrictTo") public void showChooseThemePopup(View anchor) { PopupMenu popupMenu = new PopupMenu(context, anchor); popupMenu.inflate(R.menu.mtrl_choose_theme_menu); if (popupMenu.getMenu() instanceof MenuBuilder) { MenuBuilder menuBuilder = (MenuBuilder) popupMenu.getMenu(); menuBuilder.setOptionalIconsVisible(true); ColorStateList defaultColor = AppCompatResources.getColorStateList( context, R.color.material_on_surface_emphasis_medium); int selectedColor = MaterialColors.getColor(anchor, resourceProvider.getPrimaryColor()); int currentThemeId = getCurrentThemeId(); for (int i = 0; i < menuBuilder.size(); i++) { MenuItem item = menuBuilder.getItem(i); if (item.getItemId() == currentThemeId) { DrawableCompat.setTint(item.getIcon(), selectedColor); SpannableString s = new SpannableString(item.getTitle()); s.setSpan(new ForegroundColorSpan(selectedColor), 0, s.length(), 0); item.setTitle(s); } else { DrawableCompat.setTintList(item.getIcon(), defaultColor); } } } popupMenu.setOnMenuItemClickListener( item -> { saveAndApplyTheme(item.getItemId()); return false; }); popupMenu.show(); }
Example 11
Source Project: Carbon File: BottomNavigationView.java License: Apache License 2.0 | 5 votes |
public Item(MenuItem menuItem) { id = menuItem.getItemId(); try { // breaks preview this.icon = menuItem.getIcon(); } catch (Exception e) { } this.text = menuItem.getTitle(); iconTint = MenuItemCompat.getIconTintList(menuItem); }
Example 12
Source Project: shortyz File: HTMLActivity.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getTitle() == null){ finish(); return true; } return false; }
Example 13
Source Project: guarda-android-wallets File: MainActivity.java License: GNU General Public License v3.0 | 4 votes |
private void applyFontToMenuItem(MenuItem mi) { Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf"); SpannableString mNewTitle = new SpannableString(mi.getTitle()); mNewTitle.setSpan(new RobotoLightTypefaceSpan("", font), 0, mNewTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); mi.setTitle(mNewTitle); }
Example 14
Source Project: fab-speed-dial File: FabSpeedDial.java License: Apache License 2.0 | 4 votes |
private View createFabMenuItem(MenuItem menuItem) { ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext()) .inflate(getMenuItemLayoutId(), this, false); FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab); CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view); TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view); fabMenuItemMap.put(miniFab, menuItem); cardViewMenuItemMap.put(cardView, menuItem); miniFab.setImageDrawable(menuItem.getIcon()); miniFab.setOnClickListener(this); cardView.setOnClickListener(this); ViewCompat.setAlpha(miniFab, 0f); ViewCompat.setAlpha(cardView, 0f); final CharSequence title = menuItem.getTitle(); if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) { cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor()); titleView.setText(title); titleView.setTypeface(null, Typeface.BOLD); titleView.setTextColor(miniFabTitleTextColor); if (miniFabTitleTextColorArray != null) { titleView.setTextColor(ContextCompat.getColorStateList(getContext(), miniFabTitleTextColorArray[menuItem.getOrder()])); } } else { fabMenuItem.removeView(cardView); } miniFab.setBackgroundTintList(miniFabBackgroundTint); if (miniFabBackgroundTintArray != null) { miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(), miniFabBackgroundTintArray[menuItem.getOrder()])); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { miniFab.setImageTintList(miniFabDrawableTint); } return fabMenuItem; }
Example 15
Source Project: Cook-It-Android-XML-Template File: Main.java License: MIT License | 4 votes |
private void applyFontToMenuItem(MenuItem mi) { Typeface font = Typeface.createFromAsset(getAssets(), "fonts/SourceSansPro-Semibold.otf"); SpannableString mNewTitle = new SpannableString(mi.getTitle()); mNewTitle.setSpan(new CustomTypefaceSpan("" , font), 0 , mNewTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); mi.setTitle(mNewTitle); }
Example 16
Source Project: Carbon File: FloatingActionMenu.java License: Apache License 2.0 | 4 votes |
public Item(MenuItem item) { icon = item.getIcon(); tint = MenuItemCompat.getIconTintList(item); enabled = item.isEnabled(); title = item.getTitle(); }
Example 17
Source Project: BottomSheetMenu File: BottomSheetUtils.java License: Apache License 2.0 | 4 votes |
public static void setMenuItemTextColor(MenuItem menuItem, @ColorInt int textColor) { SpannableString s = new SpannableString(menuItem.getTitle()); s.setSpan(new ForegroundColorSpan(textColor), 0, s.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); menuItem.setTitle(s); }
Example 18
Source Project: SimplicityBrowser File: BottomSheetAdapterBuilder.java License: MIT License | 4 votes |
private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor, int itemTextColor, int itemBackground, int tintColor) { List<BottomSheetItem> items = new ArrayList<>(); mTitles = 0; boolean addedSubMenu = false; for (int i = 0; i < mMenu.size(); i++) { MenuItem item = mMenu.getItem(i); if (item.isVisible()) { if (item.hasSubMenu()) { SubMenu subMenu = item.getSubMenu(); if (i != 0 && addedSubMenu) { if (mMode == BottomSheetBuilder.MODE_GRID) { throw new IllegalArgumentException("MODE_GRID can't have submenus." + " Use MODE_LIST instead"); } items.add(new BottomSheetDivider(dividerBackground)); } CharSequence title = item.getTitle(); if (title != null && !title.equals("")) { items.add(new BottomSheetHeader(title.toString(), titleTextColor)); mTitles++; } for (int j = 0; j < subMenu.size(); j++) { MenuItem subItem = subMenu.getItem(j); if (subItem.isVisible()) { items.add(new BottomSheetMenuItem(subItem, itemTextColor, itemBackground, tintColor)); addedSubMenu = true; } } } else { items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor)); } } } return items; }
Example 19
Source Project: FaceT File: ShopListActivity.java License: Mozilla Public License 2.0 | 4 votes |
private void applyFontToMenuItem(MenuItem mi) { Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT); SpannableString mNewTitle = new SpannableString(mi.getTitle()); mNewTitle.setSpan(new CustomTypeFaceSpan("", fontType), 0, mNewTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); mi.setTitle(mNewTitle); }
Example 20
Source Project: FaceT File: MainActivity.java License: Mozilla Public License 2.0 | 4 votes |
private void applyFontToMenuItem(MenuItem mi) { Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT); SpannableString mNewTitle = new SpannableString(mi.getTitle()); mNewTitle.setSpan(new CustomTypeFaceSpan("", fontType), 0, mNewTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); mi.setTitle(mNewTitle); }