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

  • Home
  • SEARCH
  • 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'll try and be as precise as possible here! Basically, I have an app
I'm trying to play a sound based on which button is pressed using AVAudioPlayer.
I'm trying to stream sound from my soundcard using sox's default audio device and
Let's say I have two or more processes dealing with an SQLite database -
I've actually posted this question before, but it hasn't been answered. Maybe I wasn't
I've written a cheap & cheerful sound board in for my Mac, and I
I want to manipulate an audio stream before it gets to the soundcard. So
I've got an application that uses DirectShow/DirectSound which plays videos and extracts the video/sound.
Any ideas or working solutions for achieving polyphonic audio in Silverlight? It is possible
I'm attempting to compile SndObj, and I need some header files. Which Debian packages

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.