android.support.annotation.MenuRes Java Examples
The following examples show how to use
android.support.annotation.MenuRes.
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: SublimeNavigationView.java From SublimeNavigationView with Apache License 2.0 | 6 votes |
/** * Provides a mechanism for switching between any number of Menus. * * @param newMenuResId id of the menu that you wish * to switch to. Eg: R.menu.new_menu_id */ public void switchMenuTo(@MenuRes int newMenuResId) { if (newMenuResId < 1) { Log.e(TAG, "Could not switch to new menu: passed menuResourceId was invalid."); return; } mMenu = new SublimeMenu(newMenuResId); inflateMenu(newMenuResId); mMenu.setCallback(new SublimeMenu.Callback() { public boolean onMenuItemSelected(SublimeMenu menu, SublimeBaseMenuItem item, OnNavigationMenuEventListener.Event event) { return SublimeNavigationView.this.mEventListener != null && SublimeNavigationView.this .mEventListener.onNavigationMenuEvent(event, item); } }); mMenu.setMenuPresenter(getContext(), mPresenter); }
Example #2
Source File: BottomToolbar.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void inflateMenu(@MenuRes int resId) { super.inflateMenu(resId); Menu menu = getMenu(); MenuItem item = menu.getItem(0); int size = item.getIcon().getIntrinsicWidth() + ControlHelper.dpToPx(30, getResources()); int width = getWidth(); for (int i = 0; i < menu.size(); i++) { item = menu.getItem(i); if (size * (i + 2) < width) MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); else break; } }
Example #3
Source File: FloatingSearchView.java From FloatingSearchView with Apache License 2.0 | 6 votes |
public void inflateMenu(@MenuRes int menuRes) { if(menuRes == 0) return; if (isInEditMode()) return; getActivity().getMenuInflater().inflate(menuRes, mActionMenu.getMenu()); XmlResourceParser parser = null; try { //noinspection ResourceType parser = getResources().getLayout(menuRes); AttributeSet attrs = Xml.asAttributeSet(parser); parseMenu(parser, attrs); } catch (XmlPullParserException | IOException e) { // should not happens throw new InflateException("Error parsing menu XML", e); } finally { if (parser != null) parser.close(); } }
Example #4
Source File: SublimeNavigationView.java From SublimeNavigationView with Apache License 2.0 | 6 votes |
/** * Provides a mechanism for switching between any number of Menus. * * @param newMenuResId id of the menu that you wish * to switch to. Eg: R.menu.new_menu_id */ public void switchMenuTo(@MenuRes int newMenuResId) { if (newMenuResId < 1) { Log.e(TAG, "Could not switch to new menu: passed menuResourceId was invalid."); return; } mMenu = new SublimeMenu(newMenuResId); inflateMenu(newMenuResId); mMenu.setCallback(new SublimeMenu.Callback() { public boolean onMenuItemSelected(SublimeMenu menu, SublimeBaseMenuItem item, OnNavigationMenuEventListener.Event event) { return SublimeNavigationView.this.mEventListener != null && SublimeNavigationView.this .mEventListener.onNavigationMenuEvent(event, item); } }); mMenu.setMenuPresenter(getContext(), mPresenter); }
Example #5
Source File: FloatingSearchView.java From FloatingSearchView with Apache License 2.0 | 6 votes |
public void inflateMenu(@MenuRes int menuRes) { if(menuRes == 0) return; if (isInEditMode()) return; getActivity().getMenuInflater().inflate(menuRes, mActionMenu.getMenu()); XmlResourceParser parser = null; try { //noinspection ResourceType parser = getResources().getLayout(menuRes); AttributeSet attrs = Xml.asAttributeSet(parser); parseMenu(parser, attrs); } catch (XmlPullParserException | IOException e) { // should not happens throw new InflateException("Error parsing menu XML", e); } finally { if (parser != null) parser.close(); } }
Example #6
Source File: MenuNavigationItemsAdapter.java From fluentAppBar with Apache License 2.0 | 5 votes |
MenuNavigationItemsAdapter(Context context, @MenuRes int menuRes, View.OnClickListener onClickListener, @ColorInt int foregroundColour) { this.context = context; this.onClickListener = onClickListener; this.foregroundColour = foregroundColour; this.navItems = new ArrayList<>(); populateNavigationItems(menuRes); }
Example #7
Source File: MenuSheetView.java From ThreePhasesBottomSheet with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Inflates a menu resource into the menu backing this sheet. * * @param menuRes Menu resource ID */ public void inflateMenu(@MenuRes int menuRes) { if (menuRes != -1) { MenuInflater inflater = new MenuInflater(getContext()); inflater.inflate(menuRes, menu); } prepareMenuItems(); }
Example #8
Source File: BottomSheetBuilder.java From BottomSheetBuilder with Apache License 2.0 | 5 votes |
public BottomSheetBuilder setMenu(@MenuRes int menu) { @SuppressWarnings("ConstantConditions") PopupMenu popupMenu = new PopupMenu(mContext, null); mMenu = popupMenu.getMenu(); popupMenu.getMenuInflater().inflate(menu, mMenu); return setMenu(mMenu); }
Example #9
Source File: XanderPanel.java From XanderPanel with Apache License 2.0 | 5 votes |
public Builder setMenu(@MenuRes int xmlRes, PanelInterface.PanelMenuListener menuListener) { if (null == mPanelParams.actionMenu) { mPanelParams.actionMenu = new ActionMenu(mContext); } (new MenuInflater(mContext)).inflate(xmlRes, mPanelParams.actionMenu); mPanelParams.menuListener = menuListener; return this; }
Example #10
Source File: SweetSheet.java From AndroidSweetSheet with Apache License 2.0 | 5 votes |
public void setMenuList(@MenuRes int menuRes) { Menu menu = new PopupMenu(mParentVG.getContext(), null).getMenu(); new MenuInflater(mParentVG.getContext()).inflate(menuRes, menu); List<MenuEntity> menuEntities = getMenuEntityFormMenuRes(menu); if(mDelegate != null) { mDelegate.setMenuList(menuEntities); }else{ mMenuEntities=menuEntities; } }
Example #11
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 #12
Source File: ColorUtils.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
public static BottomSheetMenu getThemedBottomSheetMenu(Context context, @MenuRes int menuRes) { int tintColor = PalmApp.getColorCompact(isDarkTheme() ? R.color.dark_theme_image_tint_color : R.color.light_theme_image_tint_color); BottomSheetMenu menu = new BottomSheetMenu(context); new MenuInflater(context).inflate(menuRes, menu); int size = menu.size(); for (int i=0; i<size; i++) { MenuItem menuItem = menu.getItem(i); Drawable drawable = menuItem.getIcon(); if (drawable != null) { menuItem.setIcon(ColorUtils.tintDrawable(drawable, tintColor)); } } return menu; }
Example #13
Source File: SweetSheet.java From MousePaint with MIT License | 5 votes |
public void setMenuList(@MenuRes int menuRes) { Menu menu = new PopupMenu(mParentVG.getContext(), null).getMenu(); new MenuInflater(mParentVG.getContext()).inflate(menuRes, menu); List<MenuEntity> menuEntities = getMenuEntityFormMenuRes(menu); if(mDelegate != null) { mDelegate.setMenuList(menuEntities); }else{ mMenuEntities=menuEntities; } }
Example #14
Source File: BottomSheet.java From BottomSheet with Apache License 2.0 | 5 votes |
public Builder setMenu(@MenuRes int menuResId, final OnClickListener listener) { BottomSheetMenu menu = new BottomSheetMenu(context); new MenuInflater(context).inflate(menuResId, menu); for (int i = 0; i < menu.size(); i++) { bottomSheet.ITEMS.add(menu.getItem(i).getTitle()); bottomSheet.ICONS.add(menu.getItem(i).getIcon()); } bottomSheet.onClickListener = listener; return this; }
Example #15
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 #16
Source File: MenuParserHelper.java From fluentAppBar with Apache License 2.0 | 5 votes |
public static void parseMenu(Context context, @MenuRes int menuRes, List<MenuEntry> menuEntryList){ PopupMenu p = new PopupMenu(context, null); Menu menu = p.getMenu(); new MenuInflater(context).inflate(menuRes, menu); for (int i = 0; i < menu.size(); i++) { android.view.MenuItem item = menu.getItem(i); menuEntryList.add(new MenuEntry(item.getTitle().toString(), item.getIcon(), item.getItemId())); } }
Example #17
Source File: FluentAppBar.java From fluentAppBar with Apache License 2.0 | 5 votes |
public void setSecondaryMenu(@MenuRes int menuRes, OnClickListener onClickListener) { RecyclerView recyclerView = (RecyclerView) findViewById(R.id.secondary_menu_items_recyler); recyclerView.setNestedScrollingEnabled(false); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); menuSecondaryItemsAdapter = new MenuSecondaryItemsAdapter(getContext(), menuRes, onClickListener, foregroundColour); recyclerView.setAdapter(menuSecondaryItemsAdapter); }
Example #18
Source File: FluentAppBar.java From fluentAppBar with Apache License 2.0 | 5 votes |
public void setNavigationMenu(@MenuRes int menuRes, OnClickListener onClickListener) { RecyclerView recyclerView = (RecyclerView) findViewById(R.id.nav_items_recycler); recyclerView.setNestedScrollingEnabled(false); recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); menuNavigationItemsAdapter = new MenuNavigationItemsAdapter(getContext(), menuRes, onClickListener, foregroundColour); recyclerView.setAdapter(menuNavigationItemsAdapter); }
Example #19
Source File: MenuSecondaryItemsAdapter.java From fluentAppBar with Apache License 2.0 | 5 votes |
MenuSecondaryItemsAdapter(Context context, @MenuRes int secondaryMenuId, View.OnClickListener onClickListener, @ColorInt int foregroundColour) { this.context = context; this.onClickListener = onClickListener; this.foregroundColour = foregroundColour; this.itemss = new ArrayList<>(); MenuParserHelper.parseMenu(context, secondaryMenuId, itemss); }
Example #20
Source File: BooksCollection.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
@MenuRes public int getMoreMenuRes() { if (isAutomatic()) { return R.menu.automatic_collection; } else { if (!isFavourie()) { return R.menu.user_collection; } else { return R.menu.favourite_collection; } } }
Example #21
Source File: MenuSheetView.java From bottomsheet with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Inflates a menu resource into the menu backing this sheet. * * @param menuRes Menu resource ID */ public void inflateMenu(@MenuRes int menuRes) { if (menuRes != -1) { SupportMenuInflater inflater = new SupportMenuInflater(getContext()); inflater.inflate(menuRes, menu); } prepareMenuItems(); }
Example #22
Source File: CustomAppBar.java From MaterialMasterDetail with Apache License 2.0 | 5 votes |
public void setMenuRes(@MenuRes int menuGeneral, @MenuRes int menuSpecific, @MenuRes int menuMerged) { toolbarSpecific.getMenu().clear(); if (toolbarGeneral != null) { toolbarGeneral.getMenu().clear(); toolbarGeneral.inflateMenu(menuGeneral); toolbarSpecific.inflateMenu(menuSpecific); } else { toolbarSpecific.inflateMenu(menuMerged); } }
Example #23
Source File: ListItemView.java From ListItemView with Apache License 2.0 | 5 votes |
/** * Inflates the menu items from * an xml resource. * * @param menuId a menu xml resource identifier */ public void inflateMenu(@MenuRes final int menuId) { mMenuId = menuId; mMenuBuilder = null; mMenuView.reset(menuId, mMenuItemsRoom); adjustPadding(); }
Example #24
Source File: BottomNavigationViewScene.java From scene with Apache License 2.0 | 4 votes |
@MenuRes protected abstract int getMenuResId();
Example #25
Source File: SearchBox.java From WeGit with Apache License 2.0 | 4 votes |
public void setOverflowMenu(@MenuRes int overflowMenuResId) { overflow.setVisibility(VISIBLE); popupMenu = new PopupMenu(context, overflow); popupMenu.getMenuInflater().inflate(overflowMenuResId, popupMenu.getMenu()); }
Example #26
Source File: BaseNavigationActivity.java From ETHWallet with GNU General Public License v3.0 | 4 votes |
protected void setBottomMenu(@MenuRes int menuRes) { navigation.getMenu().clear(); navigation.inflateMenu(menuRes); }
Example #27
Source File: MenuOptionConfiguration.java From android-transition with Apache License 2.0 | 4 votes |
public MenuOptionConfiguration(@NonNull MenuItemTransition transition, @MenuRes int menuId) { mTransition = transition; mMenuId = menuId; }
Example #28
Source File: BaseActivity.java From android-md-core with Apache License 2.0 | 4 votes |
@MenuRes protected int getOptionsMenuId() { return 0; }
Example #29
Source File: BaseNavigationActivity.java From trust-wallet-android-source with GNU General Public License v3.0 | 4 votes |
protected void setBottomMenu(@MenuRes int menuRes) { navigation.getMenu().clear(); navigation.inflateMenu(menuRes); }
Example #30
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); }