Пример #1
0
 public virtual bool onKey(android.content.DialogInterface dialog, int keyCode, android.view.KeyEvent
                           @event)
 {
     if (keyCode == android.view.KeyEvent.KEYCODE_MENU || keyCode == android.view.KeyEvent
         .KEYCODE_BACK)
     {
         if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount
                 () == 0)
         {
             android.view.Window win = mDialog.getWindow();
             if (win != null)
             {
                 android.view.View decor = win.getDecorView();
                 if (decor != null)
                 {
                     android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
                     if (ds != null)
                     {
                         ds.startTracking(@event, this);
                         return(true);
                     }
                 }
             }
         }
         else
         {
             if (@event.getAction() == android.view.KeyEvent.ACTION_UP && [email protected]())
             {
                 android.view.Window win = mDialog.getWindow();
                 if (win != null)
                 {
                     android.view.View decor = win.getDecorView();
                     if (decor != null)
                     {
                         android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState();
                         if (ds != null && ds.isTracking(@event))
                         {
                             mMenu.close(true);
                             dialog.dismiss();
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     // Menu shortcut matching
     return(mMenu.performShortcut(keyCode, @event, 0));
 }
Пример #2
0
		/// <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();
		}
Пример #3
0
 /// <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();
 }