I would like to have two options menus in Android that are triggered using buttons inside the activity. Is this possible? If so, how would I go about doing so?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
I’m not sure if there’s a direct way of doing this, but there is kind of a work around. You could create the method that launches the menu the regular way, by declaring
public boolean onCreateOptionsMenu(Menu menu)and/orpublic boolean onPrepareOptionsMenu(Menu menu)but have two different “modes”. From your button, you can programmatically open the options menu by simply callingopenOptionsMenu(). Just before you open the menu, just set the “mode” to whatever the button’s menu should be in. I hope you understand what I mean, let me know if you need clarifying!