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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:07:38+00:00 2026-06-03T06:07:38+00:00

i have an issue regarding a item from a menu to act like a

  • 0

i have an issue regarding a item from a menu to act like a Button, and i don’t know how to solve it.

In a item from menu i refeer to a item expandable like this:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+id/item1" android:title="Item1" />
  <item android:id="@+id/item2" android:title="Item2" />
</menu>

and i dont know how to define it, and use it like a button, like this:

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Button button = (Button) findViewById(R.id.button);

  button.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
      String uri=null;

      Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
      intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
                      RingtoneManager.TYPE_RINGTONE);
      if (uri !=null) {
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
                        Uri.parse(uri));        
      } else {
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
                        (Uri)null);
      }

      startActivityForResult(intent, 1);
    }
  });

Thanks in advance,

  • 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-03T06:07:39+00:00Added an answer on June 3, 2026 at 6:07 am

    So you want to implement a menu. For API 10 or lower, put menu.xml in res/menu/ and override these two functions in your activity:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()) {
        case R.id.item1:
            // Do something
            break;
        case R.id.item2:
            // Do something else
            break;
        }
        return true;
    }
    

    For API 11+, consider using an action bar as explained here.

    Update

    For Preferences menus you will want to use findPreference() and define a custom setOnPreferenceClickListener(). Rather than copying code snippets here, follow any of these three detailed tutorials:

    • http://www.kaloer.com/android-preferences
    • http://androidpartaker.wordpress.com/tag/ringtonepreference/
    • http://www.bogotobogo.com/Android/android16Preferences.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are tons of threads regarding this issue but I have not
I have an issue regarding to auto populating a select dropdown from jQuery/JSON data
I have an issue regarding Sendkeys Class, as i want to use this class
I have seen a few posts regarding this issue but not one specific to
I have gone through many posts on SO regarding this issue: Tried everything in
I have looked at the different questions regarding this issue, but couldn't find anything
i have a design issue regarding sending user data from a mobile phone app
Okay I know this may sound like any other issues regarding the ListView and
I have recently encountered a very specific issue/requirement regarding an Android Button and ListView
I have an issue regarding an recursive count which works well in SQL server,

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.