Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7945523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:53:24+00:00 2026-06-04T00:53:24+00:00

How to open a context menu on click of menu button on android device?

  • 0

How to open a context menu on click of menu button on android device? Can anyone help me please..

@Override  
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {  
    super.onCreateContextMenu(menu, v, menuInfo);  
    menu.setHeaderTitle("Select");  
    menu.add(0, v.getId(), 0, "Gmail");  
    menu.add(0, v.getId(), 0, "Facebook");
    menu.add(0, v.getId(), 0, "Twitter");  
}  

@Override  
public boolean onContextItemSelected(MenuItem item) {  
    if(item.getTitle()=="Gmail"){function1(item.getItemId());}  
    else if(item.getTitle()=="Facebook"){function2(item.getItemId());}  
    else if(item.getTitle()=="Twitter"){function3(item.getItemId());}  

    return true;  
}  

How open the above context menu on click of menu button ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:53:26+00:00Added an answer on June 4, 2026 at 12:53 am
    Are you sure you want to open context Menu on Click of Menu button?
    

    Because, Context Menu is for a specific view,

    A contextual menu offers actions that affect a specific item or context frame in the UI. You can provide a context menu for any view, but they are most often used for items in a ListView, GridView, or other view collections in which the user can perform direct actions on each item.

    To show a context menu on long click, most clients will want to call registerForContextMenu(View) and override onCreateContextMenu(ContextMenu, View, ContextMenu.ContextMenuInfo).

    For menu Button of device you can use an Options Menu

    Update:

    I never try this, but you can do something like,

    1. Handle Menu button press event of device,

      public boolean onKeyUp(int keyCode, KeyEvent event) {
          if (keyCode == KeyEvent.KEYCODE_MENU) {
               // ........
           }
          return true;
       }
      
    2. Put line inside it,

      this.openContextMenu(view); // Here view is reference for which you have a register contect menu.. 
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently making a context menu which open from left button click instead
How to open context menu on left click instead of right click in silverlight
I made context menu for UltrawinGrid, when i click right mouse button then the
I need to open context menu by one click on view. I have already
I want to use the exclusive key to open context menu that are available
I have been unable to figure out how to keep a context menu open
I do open Keyboard on Button click and i store all keypress value in
I am creating a system tray program with a shortcut/context menu, but I can't
I have a context menu in wp7 <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenu x:Name=onHoldContextMenu> <toolkit:MenuItem Header=Delete Tag={Binding} Click=DeleteVisitorNote_Click
I've several buttons registered for context menu how do I know which button was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.