android.support.v7.widget.Toolbar.OnMenuItemClickListener Java Examples
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: SelectableListLayout.java From 365browser with Apache License 2.0 | 6 votes |
/** * Initializes the SelectionToolbar. * * @param toolbarLayoutId The resource id of the toolbar layout. This will be inflated into * a ViewStub. * @param delegate The SelectionDelegate that will inform the toolbar of selection changes. * @param titleResId The resource id of the title string. May be 0 if this class shouldn't set * set a title when the selection is cleared. * @param drawerLayout The DrawerLayout whose navigation icon is displayed in this toolbar. * @param normalGroupResId The resource id of the menu group to show when a selection isn't * established. * @param selectedGroupResId The resource id of the menu item to show when a selection is * established. * @param normalBackgroundColorResId The resource id of the color to use as the background color * when selection is not enabled. If null the default appbar * background color will be used. * @param listener The OnMenuItemClickListener to set on the toolbar. * @return The initialized SelectionToolbar. */ public SelectableListToolbar<E> initializeToolbar(int toolbarLayoutId, SelectionDelegate<E> delegate, int titleResId, @Nullable DrawerLayout drawerLayout, int normalGroupResId, int selectedGroupResId, @Nullable Integer normalBackgroundColorResId, @Nullable OnMenuItemClickListener listener) { mToolbarStub.setLayoutResource(toolbarLayoutId); @SuppressWarnings("unchecked") SelectableListToolbar<E> toolbar = (SelectableListToolbar<E>) mToolbarStub.inflate(); mToolbar = toolbar; mToolbar.initialize(delegate, titleResId, drawerLayout, normalGroupResId, selectedGroupResId, normalBackgroundColorResId); if (listener != null) { mToolbar.setOnMenuItemClickListener(listener); } mToolbarShadow = (FadingShadowView) findViewById(R.id.shadow); mToolbarShadow.init( ApiCompatibilityUtils.getColor(getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); delegate.addObserver(this); setToolbarShadowVisibility(); return mToolbar; }
Example #2
Source File: EditorView.java From delion with Apache License 2.0 | 5 votes |
/** * Prepares the toolbar for use. * * Many of the things that would ideally be set as attributes don't work and need to be set * programmatically. This is likely due to how we compile the support libraries. */ private void prepareToolbar() { EditorDialogToolbar toolbar = (EditorDialogToolbar) mLayout.findViewById(R.id.action_bar); toolbar.setTitle(mEditorModel.getTitle()); toolbar.setTitleTextColor(Color.WHITE); toolbar.setShowDeleteMenuItem(false); // Show the help article when the user asks. toolbar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { launchAutofillHelpPage(mContext); return true; } }); // Cancel editing when the user hits the back arrow. toolbar.setNavigationContentDescription(R.string.cancel); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancelEdit(); } }); // Make it appear that the toolbar is floating by adding a shadow. FadingShadowView shadow = (FadingShadowView) mLayout.findViewById(R.id.shadow); shadow.init(ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); // The top shadow is handled by the toolbar, so hide the one used in the field editor. // TODO(dfalcantara): Make the toolbar's shadow cover the field editor instead of pushing // it down. Maybe use a RelativeLayout with overlapping views? FadingEdgeScrollView scrollView = (FadingEdgeScrollView) mLayout.findViewById(R.id.scroll_view); scrollView.setShadowVisibility(false, true); }
Example #3
Source File: EditorView.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Prepares the toolbar for use. * * Many of the things that would ideally be set as attributes don't work and need to be set * programmatically. This is likely due to how we compile the support libraries. */ private void prepareToolbar() { EditorDialogToolbar toolbar = (EditorDialogToolbar) mLayout.findViewById(R.id.action_bar); toolbar.setTitle(mEditorModel.getTitle()); toolbar.setTitleTextColor(Color.WHITE); toolbar.setShowDeleteMenuItem(false); // Show the help article when the user asks. toolbar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { launchAutofillHelpPage(mContext); return true; } }); // Cancel editing when the user hits the back arrow. toolbar.setNavigationContentDescription(R.string.cancel); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancelEdit(); } }); // Make it appear that the toolbar is floating by adding a shadow. FadingShadowView shadow = (FadingShadowView) mLayout.findViewById(R.id.shadow); shadow.init(ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); // The top shadow is handled by the toolbar, so hide the one used in the field editor. FadingEdgeScrollView scrollView = (FadingEdgeScrollView) mLayout.findViewById(R.id.scroll_view); scrollView.setShadowVisibility(false, true); }
Example #4
Source File: EditorDialog.java From 365browser with Apache License 2.0 | 5 votes |
/** * Prepares the toolbar for use. * * Many of the things that would ideally be set as attributes don't work and need to be set * programmatically. This is likely due to how we compile the support libraries. */ private void prepareToolbar() { EditorDialogToolbar toolbar = (EditorDialogToolbar) mLayout.findViewById(R.id.action_bar); toolbar.setTitle(mEditorModel.getTitle()); toolbar.setTitleTextColor(Color.WHITE); toolbar.setShowDeleteMenuItem(false); // Show the help article when the user asks. toolbar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { launchAutofillHelpPage(mContext); return true; } }); // Cancel editing when the user hits the back arrow. toolbar.setNavigationContentDescription(R.string.cancel); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissDialog(); } }); // Make it appear that the toolbar is floating by adding a shadow. FadingShadowView shadow = (FadingShadowView) mLayout.findViewById(R.id.shadow); shadow.init(ApiCompatibilityUtils.getColor( mContext.getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); // The top shadow is handled by the toolbar, so hide the one used in the field editor. FadingEdgeScrollView scrollView = (FadingEdgeScrollView) mLayout.findViewById(R.id.scroll_view); scrollView.setEdgeVisibility( FadingEdgeScrollView.DRAW_NO_EDGE, FadingEdgeScrollView.DRAW_FADING_EDGE); }
Example #5
Source File: SelectableListLayout.java From AndroidChromium with Apache License 2.0 | 3 votes |
/** * Initializes the SelectionToolbar. * * @param toolbarLayoutId The resource id of the toolbar layout. This will be inflated into * a ViewStub. * @param delegate The SelectionDelegate that will inform the toolbar of selection changes. * @param titleResId The resource id of the title string. May be 0 if this class shouldn't set * set a title when the selection is cleared. * @param drawerLayout The DrawerLayout whose navigation icon is displayed in this toolbar. * @param normalGroupResId The resource id of the menu group to show when a selection isn't * established. * @param selectedGroupResId The resource id of the menu item to show when a selection is * established. * @param listener The OnMenuItemClickListener to set on the toolbar. * @return The initialized SelectionToolbar. */ public <E> SelectionToolbar<E> initializeToolbar(int toolbarLayoutId, SelectionDelegate<E> delegate, int titleResId, @Nullable DrawerLayout drawerLayout, int normalGroupResId, int selectedGroupResId, OnMenuItemClickListener listener) { mToolbarStub.setLayoutResource(toolbarLayoutId); @SuppressWarnings("unchecked") SelectionToolbar<E> toolbar = (SelectionToolbar<E>) mToolbarStub.inflate(); toolbar.initialize(delegate, titleResId, drawerLayout, normalGroupResId, selectedGroupResId); toolbar.setOnMenuItemClickListener(listener); return toolbar; }