Пример #1
0
        //*****************************************************
        //*
        //*		Context Menu Creation
        //*
        //*****************************************************

        /// <summary>
        /// Shows the context menu using the given region as an anchor point. </summary>
        /// <param name="displayRect"> </param>
        protected void ShowContextMenu(Rect displayRect)
        {
            // Don't show this twice
            if (mContextMenuVisible)
            {
                return;
            }

            // Don't use empty rect
            //if(displayRect.isEmpty()){
            if (displayRect.Right <= displayRect.Left)
            {
                return;
            }

            //Copy action item
            ActionItem buttonOne = new ActionItem();

            buttonOne.Title    = "Button 1";
            buttonOne.ActionId = 1;
            buttonOne.Icon     = Resources.GetDrawable(Resource.Drawable.menu_search);


            //Highlight action item
            ActionItem buttonTwo = new ActionItem();

            buttonTwo.Title    = "Button 2";
            buttonTwo.ActionId = 2;
            buttonTwo.Icon     = Resources.GetDrawable(Resource.Drawable.menu_info);

            ActionItem buttonThree = new ActionItem();

            buttonThree.Title    = "Button 3";
            buttonThree.ActionId = 3;
            buttonThree.Icon     = Resources.GetDrawable(Resource.Drawable.menu_eraser);

            // The action menu
            mContextMenu = new QuickAction(Context);
            mContextMenu.OnDismissListener = this;

            // Add buttons
            mContextMenu.AddActionItem(buttonOne);

            mContextMenu.AddActionItem(buttonTwo);

            mContextMenu.AddActionItem(buttonThree);

            //setup the action item click listener
            mContextMenu.OnActionItemClickListener = new OnActionItemClickListenerAnonymousInnerClassHelper(this);

            mContextMenuVisible = true;
            mContextMenu.Show(this, displayRect);
        }
Пример #2
0
            public void OnItemClick(QuickAction source, int pos, int actionId)
            {
                // TODO Auto-generated method stub
                if (actionId == 1)
                {
                    // Do Button 1 stuff
                    Console.WriteLine(TAG + " Hit Button 1");
                }
                else if (actionId == 2)
                {
                    // Do Button 2 stuff
                    Console.WriteLine(TAG + " Hit Button 2");
                }
                else if (actionId == 3)
                {
                    // Do Button 3 stuff
                    Console.WriteLine(TAG + " Hit Button 3");
                }

                outerInstance.mContextMenuVisible = false;
            }