Example #1
0
 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);
 }