public virtual bool tryShow() { mPopup = new android.widget.ListPopupWindow(mContext, null, [email protected] .popupMenuStyle); mPopup.setOnDismissListener(this); mPopup.setOnItemClickListener(this); mAdapter = new [email protected](this, mMenu ); mPopup.setAdapter(mAdapter); mPopup.setModal(true); android.view.View anchor = mAnchorView; if (anchor != null) { bool addGlobalListener = mTreeObserver == null; mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest if (addGlobalListener) { mTreeObserver.addOnGlobalLayoutListener(this); } anchor.addOnAttachStateChangeListener(this); mPopup.setAnchorView(anchor); } else { return(false); } mPopup.setContentWidth(System.Math.Min(measureContentWidth(mAdapter), mPopupMaxWidth )); mPopup.setInputMethodMode(android.widget.PopupWindow.INPUT_METHOD_NOT_NEEDED); mPopup.show(); mPopup.getListView().setOnKeyListener(this); return(true); }
/// <summary>Shows the popup no matter if it was already showing.</summary> /// <remarks>Shows the popup no matter if it was already showing.</remarks> /// <param name="maxActivityCount">The max number of activities to display.</param> private void showPopupUnchecked(int maxActivityCount) { if (mAdapter.getDataModel() == null) { throw new System.InvalidOperationException("No data model. Did you call #setDataModel?" ); } getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); bool defaultActivityButtonShown = mDefaultActivityButton.getVisibility() == VISIBLE; int activityCount = mAdapter.getActivityCount(); int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0; if (maxActivityCount != android.widget.ActivityChooserView.ActivityChooserViewAdapter .MAX_ACTIVITY_COUNT_UNLIMITED && activityCount > maxActivityCount + maxActivityCountOffset) { mAdapter.setShowFooterView(true); mAdapter.setMaxActivityCount(maxActivityCount - 1); } else { mAdapter.setShowFooterView(false); mAdapter.setMaxActivityCount(maxActivityCount); } android.widget.ListPopupWindow popupWindow = getListPopupWindow(); if (!popupWindow.isShowing()) { if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) { mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown); } else { mAdapter.setShowDefaultActivity(false, false); } int contentWidth = System.Math.Min(mAdapter.measureContentWidth(), mListPopupMaxWidth ); popupWindow.setContentWidth(contentWidth); popupWindow.show(); if (mProvider != null) { mProvider.subUiVisibilityChanged(true); } popupWindow.getListView().setContentDescription(java.lang.CharSequenceProxy.Wrap( mContext.getString([email protected][email protected]_choose_application ))); } }
public virtual bool tryShow() { mPopup = new android.widget.ListPopupWindow(mContext, null, [email protected] .popupMenuStyle); mPopup.setOnDismissListener(this); mPopup.setOnItemClickListener(this); mAdapter = new [email protected](this, mMenu ); mPopup.setAdapter(mAdapter); mPopup.setModal(true); android.view.View anchor = mAnchorView; if (anchor != null) { bool addGlobalListener = mTreeObserver == null; mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest if (addGlobalListener) { mTreeObserver.addOnGlobalLayoutListener(this); } anchor.addOnAttachStateChangeListener(this); mPopup.setAnchorView(anchor); } else { return false; } mPopup.setContentWidth(System.Math.Min(measureContentWidth(mAdapter), mPopupMaxWidth )); mPopup.setInputMethodMode(android.widget.PopupWindow.INPUT_METHOD_NOT_NEEDED); mPopup.show(); mPopup.getListView().setOnKeyListener(this); return true; }