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 5939837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:53:03+00:00 2026-05-22T15:53:03+00:00

In my soundboard app I have created a context menu using this code. public

  • 0

In my soundboard app I have created a context menu using this code.

public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        menu.setHeaderTitle("Choose an option");
        menu.add(0, v.getId(), 0, "Save as ringtone");
        menu.add(0, v.getId(), 0, "Save as Notification");
        menu.add(0, v.getId(), 0, "Save as Alarm");
        menu.add(0, v.getId(), 0, "Exit Menu");
}


   @Override
    public boolean onContextItemSelected(MenuItem item) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    //    Global.currentsound = info.id;
        if(item.getTitle()=="Save as ringtone"){function1(item.getItemId());}
        else if(item.getTitle()=="Save as Notification"){function2(item.getItemId());}
        else if(item.getTitle()=="Save as Alarm"){function3(item.getItemId());}
        else {return false;}
    return true;
    }

and called on the buttons like this

Button cmenu = (Button)findViewById(R.id.s1sound1);
registerForContextMenu(cmenu);

Now I want to pass the information for each button to the function in the code to set the sound according to which button was pressed. How would I do this without creating a separate context menu for each button which would be madness.

Thanks

  • 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-05-22T15:53:04+00:00Added an answer on May 22, 2026 at 3:53 pm

    I think it is stored in the “View v”, Button extends View, so you have to cast it. I’m not sure, but you can check by setting a breakpoint on the

    super.onCreateContextMenu(menu, v, menuInfo);
    

    line, and checking the debugger.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created the soundboard and the code compiles, it just wont create any sounds
My main class look like this: public class Soundboard extends Activity { SharedPreferences preferences;
I am getting stack traces like this on force close of a soundboard app.
The only way i can describe this is showing the code I have already
I'll try and be as precise as possible here! Basically, I have an app
I have a soundboard it's just a screen with about 8 buttons. each individual
I am building a soundboard with about 40 sounds using a map. (Previous thread)
I am using the following code to play a sound and after a while
I am developing a soundboard application which extends ListActivity. I have a play button
Ok well I have been fighting with this for a while now and have

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.