public virtual void initForMode(android.view.ActionMode mode) { if (mClose == null) { android.view.LayoutInflater inflater = android.view.LayoutInflater.from(mContext); mClose = inflater.inflate([email protected]_mode_close_item, this , false); addView(mClose); } else { if (mClose.getParent() == null) { addView(mClose); } } android.view.View closeButton = mClose.findViewById([email protected]_mode_close_button ); closeButton.setOnClickListener(new _OnClickListener_212(mode)); [email protected] menu = ([email protected] )mode.getMenu(); mActionMenuPresenter = new [email protected](mContext ); mActionMenuPresenter.setReserveOverflow(true); android.view.ViewGroup.LayoutParams layoutParams = new android.view.ViewGroup.LayoutParams (android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams .MATCH_PARENT); if (!mSplitActionBar) { menu.addMenuPresenter(mActionMenuPresenter); mMenuView = ([email protected])mActionMenuPresenter.getMenuView (this); mMenuView.setBackgroundDrawable(null); addView(mMenuView, layoutParams); } else { // Allow full screen width in split mode. mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics( ).widthPixels, true); // No limit to the item count; use whatever will fit. mActionMenuPresenter.setItemLimit(int.MaxValue); // Span the whole width layoutParams.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT; layoutParams.height = mContentHeight; menu.addMenuPresenter(mActionMenuPresenter); mMenuView = ([email protected])mActionMenuPresenter.getMenuView (this); mMenuView.setBackgroundDrawable(mSplitBackground); mSplitView.addView(mMenuView, layoutParams); } mAnimateInOnLayout = true; }
public MenuPopupHelper(android.content.Context context, [email protected] menu, android.view.View anchorView, bool overflowOnly) { mContext = context; mInflater = android.view.LayoutInflater.from(context); mMenu = menu; mOverflowOnly = overflowOnly; android.content.res.Resources res = context.getResources(); mPopupMaxWidth = System.Math.Max(res.getDisplayMetrics().widthPixels / 2, res.getDimensionPixelSize ([email protected]_prefDialogWidth)); mAnchorView = anchorView; menu.addMenuPresenter(this); }
/// <summary>Shows menu as a dialog.</summary> /// <remarks>Shows menu as a dialog.</remarks> /// <param name="windowToken">Optional token to assign to the window.</param> public virtual void show(android.os.IBinder windowToken) { // Many references to mMenu, create local reference [email protected] menu = mMenu; // Get the builder for the dialog android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(menu .getContext()); mPresenter = new [email protected](builder.getContext (), [email protected]_menu_item_layout); mPresenter.setCallback(this); mMenu.addMenuPresenter(mPresenter); builder.setAdapter(mPresenter.getAdapter(), this); // Set the title android.view.View headerView = menu.getHeaderView(); if (headerView != null) { // Menu's client has given a custom header view, use it builder.setCustomTitle(headerView); } else { // Otherwise use the (text) title and icon builder.setIcon(menu.getHeaderIcon()).setTitle(menu.getHeaderTitle()); } // Set the key listener builder.setOnKeyListener(this); // Show the menu mDialog = builder.create(); mDialog.setOnDismissListener(this); android.view.WindowManagerClass.LayoutParams lp = mDialog.getWindow().getAttributes (); lp.type = android.view.WindowManagerClass.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; if (windowToken != null) { lp.token = windowToken; } lp.flags |= android.view.WindowManagerClass.LayoutParams.FLAG_ALT_FOCUSABLE_IM; mDialog.show(); }