android.support.v7.view.menu.MenuBuilder Java Examples
The following examples show how to use
android.support.v7.view.menu.MenuBuilder.
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 File: LogcatActivity.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
@SuppressLint("RestrictedApi") public void invalidateDarkOrLightMenuItems(Context context, Menu menu) { if (menu != null && menu instanceof MenuBuilder) { ((MenuBuilder) menu).setOptionalIconsVisible(true); /*final boolean darkMode = ThemeUtils.isDarkMode(context); final int textColorPrimary = Utils.resolveColor(context, android.R.attr.textColorPrimary); mToolbar.post(new Runnable() { @Override public void run() { for (int i = 0; i < menu.size(); i++) { MenuItemImpl item = (MenuItemImpl) menu.getItem(i); int color = darkMode || item.isActionButton() ? Color.WHITE : textColorPrimary; if (item.getIcon() != null) { item.getIcon().setColorFilter(color, PorterDuff.Mode.SRC_IN); } } } });*/ } }
Example #2
Source File: MainActivity.java From BookReader with Apache License 2.0 | 6 votes |
/** * 显示item中的图片; * * @param view * @param menu * @return */ @Override protected boolean onPrepareOptionsPanel(View view, Menu menu) { if (menu != null) { if (menu.getClass() == MenuBuilder.class) { try { Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); m.setAccessible(true); m.invoke(menu, true); } catch (Exception e) { e.printStackTrace(); } } } return super.onPrepareOptionsPanel(view, menu); }
Example #3
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 6 votes |
public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView, boolean overflowOnly, int popupStyleAttr, int popupStyleRes) { mContext = context; mInflater = LayoutInflater.from(context); mMenu = menu; mAdapter = new MenuAdapter(mMenu); mOverflowOnly = overflowOnly; mPopupStyleAttr = popupStyleAttr; mPopupStyleRes = popupStyleRes; final Resources res = context.getResources(); mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2, res.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth)); mAnchorView = anchorView; // Present the menu using our context, not the menu builder's context. menu.addMenuPresenter(this, context); }
Example #4
Source File: MainActivity.java From fangzhuishushenqi with Apache License 2.0 | 6 votes |
/** * 显示item中的图片; * * @param view * @param menu * @return */ @Override protected boolean onPrepareOptionsPanel(View view, Menu menu) { if (menu != null) { if (menu.getClass() == MenuBuilder.class) { try { Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); m.setAccessible(true); m.invoke(menu, true); } catch (Exception e) { e.printStackTrace(); } } } return super.onPrepareOptionsPanel(view, menu); }
Example #5
Source File: LogcatActivity.java From javaide with GNU General Public License v3.0 | 6 votes |
@SuppressLint("RestrictedApi") public void invalidateDarkOrLightMenuItems(Context context, Menu menu) { if (menu != null && menu instanceof MenuBuilder) { ((MenuBuilder) menu).setOptionalIconsVisible(true); /*final boolean darkMode = ThemeUtils.isDarkMode(context); final int textColorPrimary = Utils.resolveColor(context, android.R.attr.textColorPrimary); mToolbar.post(new Runnable() { @Override public void run() { for (int i = 0; i < menu.size(); i++) { MenuItemImpl item = (MenuItemImpl) menu.getItem(i); int color = darkMode || item.isActionButton() ? Color.WHITE : textColorPrimary; if (item.getIcon() != null) { item.getIcon().setColorFilter(color, PorterDuff.Mode.SRC_IN); } } } });*/ } }
Example #6
Source File: MainActivity.java From Memory-capsule with Apache License 2.0 | 5 votes |
@SuppressLint("RestrictedApi") @Override protected boolean onPrepareOptionsPanel(View view, Menu menu) { if (menu.getClass() == MenuBuilder.class) { try { Method method = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); method.setAccessible(true); method.invoke(menu, true); } catch (Exception e) { e.printStackTrace(); } } return super.onPrepareOptionsPanel(view, menu); }
Example #7
Source File: DrawerBuilder.java From MaterialDrawer-Xamarin with Apache License 2.0 | 5 votes |
/** * Inflates the DrawerItems from a menu.xml * * @param menuRes * @return */ public DrawerBuilder inflateMenu(@MenuRes int menuRes) { MenuInflater menuInflater = new SupportMenuInflater(mActivity); MenuBuilder mMenu = new MenuBuilder(mActivity); menuInflater.inflate(menuRes, mMenu); addMenuItems(mMenu, false); return this; }
Example #8
Source File: FABRevealMenu.java From FABRevealMenu-master with Apache License 2.0 | 5 votes |
/** * Set menu from menu xml * * @param menuRes menu xml resource */ public void setMenu(@MenuRes int menuRes) { mCustomView = null; mMenuRes = menuRes; removeAllViews(); @SuppressLint("RestrictedApi") Menu menu = new MenuBuilder(getContext()); inflateMenu(menuRes, menu); setUpMenu(menu); }
Example #9
Source File: BottomDialog.java From BottomDialog with MIT License | 5 votes |
public void inflateMenu(int menu) { MenuInflater menuInflater = new SupportMenuInflater(getContext()); MenuBuilder menuBuilder = new MenuBuilder(getContext()); menuInflater.inflate(menu, menuBuilder); List<Item> items = new ArrayList<>(); for (int i = 0; i < menuBuilder.size(); i++) { MenuItem menuItem = menuBuilder.getItem(i); Item item = new Item(); item.setId(menuItem.getItemId()); item.setIcon(menuItem.getIcon()); item.setTitle(menuItem.getTitle().toString()); items.add(item); } addItems(items); }
Example #10
Source File: BottomNavigationMenuView.java From MiPushFramework with GNU General Public License v3.0 | 5 votes |
@Override public void initialize(MenuBuilder menu) { mMenu = menu; if (mMenu == null) return; if (mMenu.size() > mActiveButton) { mMenu.getItem(mActiveButton).setChecked(true); } }
Example #11
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 5 votes |
@Override public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { // Only care about the (sub)menu we're presenting. if (menu != mMenu) return; dismiss(); if (mPresenterCallback != null) { mPresenterCallback.onCloseMenu(menu, allMenusAreClosing); } }
Example #12
Source File: HassActivity.java From home-assistant-Android with GNU General Public License v3.0 | 5 votes |
@SuppressLint("RestrictedApi") @Override public boolean onCreateOptionsMenu(Menu menu) { if (menu instanceof MenuBuilder) { ((MenuBuilder) menu).setOptionalIconsVisible(true); } String packageName = CustomTabsClient.getPackageName(this, null); CustomTabsClient.bindCustomTabsService(this, !TextUtils.isEmpty(packageName) ? packageName : "com.android.chrome", chromeConnection); getMenuInflater().inflate(R.menu.hass, menu); return super.onCreateOptionsMenu(menu); }
Example #13
Source File: EditorActivity.java From spline with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { MenuPopupHelper menuHelper = new MenuPopupHelper(this, (MenuBuilder) mLayerTypePopup.getMenu(), mBinding.addLayerBtn); menuHelper.setForceShowIcon(true); menuHelper.show(); }
Example #14
Source File: MainActivity.java From NovelReader with MIT License | 5 votes |
@Override public boolean onPreparePanel(int featureId, View view, Menu menu) { if (menu != null && menu instanceof MenuBuilder){ try { Method method = menu.getClass(). getDeclaredMethod("setOptionalIconsVisible",Boolean.TYPE); method.setAccessible(true); method.invoke(menu,true); } catch (Exception e){ e.printStackTrace(); } } return super.onPreparePanel(featureId, view, menu); }
Example #15
Source File: CustomDialog.java From YCDialog with Apache License 2.0 | 5 votes |
@SuppressLint("RestrictedApi") void inflateMenu(int menu, OnItemClickListener onItemClickListener) { MenuInflater menuInflater = new SupportMenuInflater(getContext()); MenuBuilder menuBuilder = new MenuBuilder(getContext()); menuInflater.inflate(menu, menuBuilder); List<CustomItem> items = new ArrayList<>(); for (int i = 0; i < menuBuilder.size(); i++) { MenuItem menuItem = menuBuilder.getItem(i); items.add(new CustomItem(menuItem.getItemId(), menuItem.getTitle().toString(), menuItem.getIcon())); } addItems(items, onItemClickListener); }
Example #16
Source File: MenuView.java From ListItemView with Apache License 2.0 | 5 votes |
/** * Resets the the view to fit into a new available width. * <p> * This clears and then re-inflates the menu items, removes all of its associated action * views, and re-creates the menu and action items to fit in the new width. * </p> * * @param menuItemsRoom the number of the menu items to show. If * there is room, menu items that are flagged with * android:showAsAction="ifRoom" or android:showAsAction="always" * will show as actions. */ public void reset(final int menuResId, int menuItemsRoom) { mMenuResId = menuResId; //clean view and re-inflate removeAllViews(); if (mMenuResId == -1) { return; } final MenuBuilder builder = new MenuBuilder(getContext()); getMenuInflater().inflate(mMenuResId, builder); reset(builder, menuItemsRoom); }
Example #17
Source File: BottomDialog.java From imsdk-android with MIT License | 5 votes |
public void inflateMenu(int menu) { MenuInflater menuInflater = new SupportMenuInflater(getContext()); MenuBuilder menuBuilder = new MenuBuilder(getContext()); menuInflater.inflate(menu, menuBuilder); List<Item> items = new ArrayList<>(); for (int i = 0; i < menuBuilder.size(); i++) { MenuItem menuItem = menuBuilder.getItem(i); Item item = new Item(); item.setId(menuItem.getItemId()); item.setIcon(menuItem.getIcon()); item.setTitle(menuItem.getTitle().toString()); items.add(item); } addItems(items); }
Example #18
Source File: ListItemView.java From ListItemView with Apache License 2.0 | 5 votes |
/** * Inflates the menu items from menu builder * * @param menuBuilder a menu builder */ public void setMenu(final MenuBuilder menuBuilder) { mMenuBuilder = menuBuilder; mMenuId = NULL; mMenuView.reset(menuBuilder, mMenuItemsRoom); adjustPadding(); }
Example #19
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 4 votes |
public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) { return false; }
Example #20
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 4 votes |
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) { return false; }
Example #21
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 4 votes |
@Override public void initForMenu(Context context, MenuBuilder menu) { // Don't need to do anything; we added as a presenter in the constructor. }
Example #22
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 4 votes |
public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView, boolean overflowOnly, int popupStyleAttr) { this(context, menu, anchorView, overflowOnly, popupStyleAttr, 0); }
Example #23
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 4 votes |
public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView) { this(context, menu, anchorView, false, R.attr.popupMenuStyle); }
Example #24
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 4 votes |
public MenuPopupHelper(Context context, MenuBuilder menu) { this(context, menu, null, false, R.attr.popupMenuStyle); }
Example #25
Source File: MenuView.java From floatingsearchview with Apache License 2.0 | 4 votes |
private void init() { mMenuBuilder = new MenuBuilder(getContext()); mMenuPopupHelper = new MenuPopupHelper(getContext(), mMenuBuilder, this); mActionIconColor = Util.getColor(getContext(), R.color.gray_active_icon); mOverflowIconColor = Util.getColor(getContext(), R.color.gray_active_icon); }
Example #26
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 4 votes |
public MenuAdapter(MenuBuilder menu) { mAdapterMenu = menu; findExpandedIndex(); }
Example #27
Source File: AppCompatv7DSL.java From anvil with MIT License | 4 votes |
public static Void itemInvoker(MenuBuilder.ItemInvoker arg) { return BaseDSL.attr("itemInvoker", arg); }
Example #28
Source File: FloatingToolbarMenuBuilder.java From FloatingToolbar with Apache License 2.0 | 4 votes |
public FloatingToolbarMenuBuilder(Context context) { menuBuilder = new MenuBuilder(context); }
Example #29
Source File: FloatingToolbar.java From FloatingToolbar with Apache License 2.0 | 4 votes |
/** * Set a menu from it's resource id. * * @param menuRes menu resource to be set */ public void setMenu(@MenuRes int menuRes) { mMenu = new MenuBuilder(getContext()); new SupportMenuInflater(getContext()).inflate(menuRes, mMenu); setMenu(mMenu); }
Example #30
Source File: ToolbarContentTintHelper.java From APlayer with GNU General Public License v3.0 | 4 votes |
@Override public boolean onOpenSubMenu(MenuBuilder subMenu) { InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor); return mParentCb != null && mParentCb.onOpenSubMenu(subMenu); }