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 Project: SublimeNavigationView Author: vikramkakkar File: SublimeNavigationView.java License: 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 Project: FloatingSearchView Author: renaudcerrato File: FloatingSearchView.java License: 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 #3
Source Project: SublimeNavigationView Author: vikramkakkar File: SublimeNavigationView.java License: 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 #4
Source Project: FloatingSearchView Author: renaudcerrato File: FloatingSearchView.java License: 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 #5
Source Project: android_maplibui Author: nextgis File: BottomToolbar.java License: 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 #6
Source Project: OmniList Author: Shouheng88 File: ColorUtils.java License: 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 #7
Source Project: ListItemView Author: lurbas File: ListItemView.java License: 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 #8
Source Project: MaterialMasterDetail Author: lurbas File: CustomAppBar.java License: 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 #9
Source Project: IslamicLibraryAndroid Author: fekracomputers File: BooksCollection.java License: 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 #10
Source Project: fluentAppBar Author: byvlstr File: MenuSecondaryItemsAdapter.java License: 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 #11
Source Project: fluentAppBar Author: byvlstr File: FluentAppBar.java License: 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 #12
Source Project: fluentAppBar Author: byvlstr File: FluentAppBar.java License: 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 #13
Source Project: fluentAppBar Author: byvlstr File: MenuParserHelper.java License: 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 #14
Source Project: fluentAppBar Author: byvlstr File: MenuNavigationItemsAdapter.java License: 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 #15
Source Project: BottomSheet Author: michaelbel File: BottomSheet.java License: 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 #16
Source Project: FABRevealMenu-master Author: HarinTrivedi File: FABRevealMenu.java License: 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 #17
Source Project: BottomSheetBuilder Author: rubensousa File: BottomSheetBuilder.java License: 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 #18
Source Project: ThreePhasesBottomSheet Author: AndroidDeveloperLB File: MenuSheetView.java License: 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 #19
Source Project: XanderPanel Author: XanderWang File: XanderPanel.java License: 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 #20
Source Project: AndroidSweetSheet Author: zzz40500 File: SweetSheet.java License: 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 #21
Source Project: MousePaint Author: android-cjj File: SweetSheet.java License: 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 #22
Source Project: MaterialDrawer-Xamarin Author: amatkivskiy File: DrawerBuilder.java License: 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 #23
Source Project: bottomsheet Author: Flipboard File: MenuSheetView.java License: 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 #24
Source Project: scene Author: bytedance File: NavigationViewScene.java License: Apache License 2.0 | 4 votes |
@MenuRes protected abstract int getMenuResId();
Example #25
Source Project: scene Author: bytedance File: BottomNavigationViewScene.java License: Apache License 2.0 | 4 votes |
@MenuRes protected abstract int getMenuResId();
Example #26
Source Project: ETHWallet Author: snailflying File: BaseNavigationActivity.java License: GNU General Public License v3.0 | 4 votes |
protected void setBottomMenu(@MenuRes int menuRes) { navigation.getMenu().clear(); navigation.inflateMenu(menuRes); }
Example #27
Source Project: relight Author: ittianyu File: ToolbarWidget.java License: Apache License 2.0 | 4 votes |
public ToolbarWidget inflateMenu(@MenuRes int resId) { view.inflateMenu(resId); return self(); }
Example #28
Source Project: trust-wallet-android-source Author: trustwallet File: BaseNavigationActivity.java License: GNU General Public License v3.0 | 4 votes |
protected void setBottomMenu(@MenuRes int menuRes) { navigation.getMenu().clear(); navigation.inflateMenu(menuRes); }
Example #29
Source Project: FullScreenDialog Author: franmontiel File: FullScreenDialogFragment.java License: Apache License 2.0 | 4 votes |
public Builder setExtraActions(@MenuRes int menuResId) { this.extraActionsMenuResId = menuResId; return this; }
Example #30
Source Project: Orin Author: aliumujib File: AbsMultiSelectAdapter.java License: GNU General Public License v3.0 | 4 votes |
public AbsMultiSelectAdapter(Context context, @Nullable CabHolder cabHolder, @MenuRes int menuRes) { this.cabHolder = cabHolder; checked = new ArrayList<>(); this.menuRes = menuRes; this.context = context; }