Java Code Examples for android.support.v7.widget.Toolbar#OnMenuItemClickListener
The following examples show how to use
android.support.v7.widget.Toolbar#OnMenuItemClickListener .
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: NestedRecyclerViewAlbumHolder.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
static Toolbar getSelectorModeToolbar(Context context, View.OnClickListener onClickListener, Toolbar.OnMenuItemClickListener onItemClickListener) { final Toolbar toolbar = new Toolbar(context); toolbar.setTag(SELECTOR_TOOLBAR_TAG); Theme theme = Settings.getInstance(context).getThemeInstance(context); int accentColor = theme.getAccentColor(context); int accentTextColor = theme.getAccentTextColor(context); toolbar.setBackgroundColor(accentColor); toolbar.setTitleTextColor(accentTextColor); toolbar.inflateMenu(R.menu.selector_mode); toolbar.setOnMenuItemClickListener(onItemClickListener); Drawable menuIcon = toolbar.getOverflowIcon(); if (menuIcon != null) { DrawableCompat.wrap(menuIcon); DrawableCompat.setTint(menuIcon.mutate(), accentTextColor); } Drawable navIcon = ContextCompat.getDrawable(context, R.drawable.ic_clear_white); if (navIcon != null) { DrawableCompat.wrap(navIcon); DrawableCompat.setTint(navIcon.mutate(), accentTextColor); toolbar.setNavigationIcon(navIcon); } toolbar.setNavigationOnClickListener(onClickListener); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { toolbar.setElevation(context.getResources() .getDimension(R.dimen.toolbar_elevation)); } return toolbar; }
Example 2
Source File: ToolbarContentTintHelper.java From APlayer with GNU General Public License v3.0 | 5 votes |
public ATHOnMenuItemClickListener(Context context, final @ColorInt int color, Toolbar.OnMenuItemClickListener parentCb, Toolbar toolbar) { mContext = context; mColor = color; mParentListener = parentCb; mToolbar = toolbar; }
Example 3
Source File: ToolbarWidget.java From relight with Apache License 2.0 | 4 votes |
public ToolbarWidget onMenuItemClick(Toolbar.OnMenuItemClickListener listener) { view.setOnMenuItemClickListener(listener); return self(); }
Example 4
Source File: BaseFragment.java From alpha-wallet-android with MIT License | 4 votes |
protected void toolbar(View view, int menuResId, Toolbar.OnMenuItemClickListener listener) { initToolbar(view); setToolbarMenu(menuResId); setToolbarMenuItemClickListener(listener); }
Example 5
Source File: BaseFragment.java From alpha-wallet-android with MIT License | 4 votes |
protected void toolbar(View view, int title, int menuResId, Toolbar.OnMenuItemClickListener listener) { initToolbar(view); setToolbarTitle(title); setToolbarMenu(menuResId); setToolbarMenuItemClickListener(listener); }
Example 6
Source File: BaseFragment.java From alpha-wallet-android with MIT License | 4 votes |
protected void setToolbarMenuItemClickListener(Toolbar.OnMenuItemClickListener listener) { toolbar.setOnMenuItemClickListener(listener); }
Example 7
Source File: ToolbarContentTintHelper.java From APlayer with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar, @Nullable Menu menu, final @ColorInt int toolbarContentColor, final @ColorInt int titleTextColor, final @ColorInt int subtitleTextColor, final @ColorInt int menuWidgetColor) { if (toolbar == null) { return; } if (menu == null) { menu = toolbar.getMenu(); } toolbar.setTitleTextColor(titleTextColor); toolbar.setSubtitleTextColor(subtitleTextColor); if (toolbar.getNavigationIcon() != null) { // Tint the toolbar navigation icon (e.g. back, drawer, etc.) toolbar.setNavigationIcon( TintHelper.createTintedDrawable(toolbar.getNavigationIcon(), toolbarContentColor)); } InternalToolbarContentTintUtil.tintMenu(toolbar, menu, toolbarContentColor); InternalToolbarContentTintUtil.applyOverflowMenuTint(context, toolbar, menuWidgetColor); if (context instanceof Activity) { InternalToolbarContentTintUtil .setOverflowButtonColor((Activity) context, toolbarContentColor); } try { // Tint immediate overflow menu items final Field menuField = Toolbar.class.getDeclaredField("mMenuBuilderCallback"); menuField.setAccessible(true); final Field presenterField = Toolbar.class.getDeclaredField("mActionMenuPresenterCallback"); presenterField.setAccessible(true); final Field menuViewField = Toolbar.class.getDeclaredField("mMenuView"); menuViewField.setAccessible(true); final MenuPresenter.Callback currentPresenterCb = (MenuPresenter.Callback) presenterField .get(toolbar); if (!(currentPresenterCb instanceof ATHMenuPresenterCallback)) { final ATHMenuPresenterCallback newPresenterCb = new ATHMenuPresenterCallback(context, menuWidgetColor, currentPresenterCb, toolbar); final MenuBuilder.Callback currentMenuCb = (MenuBuilder.Callback) menuField.get(toolbar); toolbar.setMenuCallbacks(newPresenterCb, currentMenuCb); ActionMenuView menuView = (ActionMenuView) menuViewField.get(toolbar); if (menuView != null) { menuView.setMenuCallbacks(newPresenterCb, currentMenuCb); } } // OnMenuItemClickListener to tint submenu items final Field menuItemClickListener = Toolbar.class .getDeclaredField("mOnMenuItemClickListener"); menuItemClickListener.setAccessible(true); Toolbar.OnMenuItemClickListener currentClickListener = (Toolbar.OnMenuItemClickListener) menuItemClickListener .get(toolbar); if (!(currentClickListener instanceof ATHOnMenuItemClickListener)) { final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context, menuWidgetColor, currentClickListener, toolbar); toolbar.setOnMenuItemClickListener(newClickListener); } } catch (Exception e) { e.printStackTrace(); } }
Example 8
Source File: AppCompatv7DSL.java From anvil with MIT License | 4 votes |
public static Void onMenuItemClick(Toolbar.OnMenuItemClickListener arg) { return BaseDSL.attr("onMenuItemClick", arg); }
Example 9
Source File: ToolBarUtil.java From Android-Architecture with Apache License 2.0 | 2 votes |
/** * 向Toolbar添加menu,一般fragment使用 * * @param toolbar * @param layout * @param itemClickListener */ public static void addMenu(Toolbar toolbar, int layout, Toolbar.OnMenuItemClickListener itemClickListener) { if (toolbar == null) return; toolbar.inflateMenu(layout); toolbar.setOnMenuItemClickListener(itemClickListener); }
Example 10
Source File: ZhiHuDetailIView.java From MeiZiNews with MIT License | 2 votes |
public void setOnMenuItemClickListener(Toolbar.OnMenuItemClickListener onMenuItemClickListener) { toolbar.setOnMenuItemClickListener(onMenuItemClickListener); }
Example 11
Source File: MainIView.java From MeiZiNews with MIT License | 2 votes |
public void setOnMenuItemClickListener(Toolbar.OnMenuItemClickListener onMenuItemClickListener) { toolbar.setOnMenuItemClickListener(onMenuItemClickListener); }
Example 12
Source File: DevWeekDetailIVew.java From MeiZiNews with MIT License | 2 votes |
public void setOnMenuItemClickListener(Toolbar.OnMenuItemClickListener onMenuItemClickListener) { toolbar.setOnMenuItemClickListener(onMenuItemClickListener); }
Example 13
Source File: MzituListIView.java From MeiZiNews with MIT License | 2 votes |
public void setOnMenuItemClickListener(Toolbar.OnMenuItemClickListener onMenuItemClickListener) { toolbar.setOnMenuItemClickListener(onMenuItemClickListener); }
Example 14
Source File: PhotoDetailIView.java From MeiZiNews with MIT License | 2 votes |
public void setOnMenuItemClickListener(Toolbar.OnMenuItemClickListener listener) { toolbar.setOnMenuItemClickListener(listener); }
Example 15
Source File: OptionView.java From SwipeableCard with Apache License 2.0 | 2 votes |
/** * Get toolbarListener of Swipeable Card. * @return OnMenuItemClickListener item */ public Toolbar.OnMenuItemClickListener getToolbarListener() { return mToolbarListener; }