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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:11:19+00:00 2026-05-17T01:11:19+00:00

I have this menu example But in this example new activity is not called,

  • 0
      I have this menu example But in this example new activity is not called,
      please give me the solution

      package Com.ContactProject;





      import android.app.Activity;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.MenuInflater;
      import android.view.Menu;

      import android.view.MenuItem;

     public class Contact extends Activity {
      /** Called when the activity is first created. */
       private static final int MENU_NEW_GAME = 0;
       private static final int MENU_QUIT = 1;
       private static final int MENU_COUNTRIES = 2;

       @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.main);



}
public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    return true;

}

public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case MENU_NEW_GAME:
        Intent cityMap = new Intent(Contact.this, Add.class);
        startActivity(cityMap);
        //newGame();
        return true;
    case MENU_QUIT:
        Intent cityMap1 = new Intent(Contact.this, Sms.class);
        startActivity(cityMap1);
        //quit();
        return true;
    case MENU_COUNTRIES:
        Intent cityMap2 = new Intent(Contact.this, Update.class);
        startActivity(cityMap2);
        return true;

    default:

    }
    return false;
}

}

  • 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-17T01:11:20+00:00Added an answer on May 17, 2026 at 1:11 am

    Your Switch case must be like the following

    Code borrowed from here

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
        case R.id.new_game:
            newGame();
            return true;
        case R.id.quit:
            quit();
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
    

    Don’t use your own Constants, use the ones that are generated in R file.

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

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Im sure theres plenty of links been posted to get… May 17, 2026 at 2:22 am
  • Editorial Team
    Editorial Team added an answer Converters (or any resource) can be declared at any level… May 17, 2026 at 2:22 am
  • Editorial Team
    Editorial Team added an answer Use WMI using System.Management; private static string GetProcessorID() { ManagementClass… May 17, 2026 at 2:22 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Can anybody tell me why is this not working. I have created a WCF
According to http://msdn.microsoft.com/en-us/library/aa984351%28VS.71%29.aspx Disabling the first or toplevel menu item in a menu (for
I have been unable to figure out how to keep a context menu open
thanks for taking the time to read this. I have a JavaScript (jQuery) navigation
I have designed some popup moving menu with JQuery, it looks perfekt in webkit
I have a Menu and Submenu structure in Silverlight, and I want the submenu
We have a case where we only know the icon for a menu item
I am creating a menu that will have its menu items injected into it
I have a very simple application with a form, a richedit and a menu.
Guys, I need some help! I have a fully rendered menu (a safe html

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.