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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:38:59+00:00 2026-05-15T23:38:59+00:00

i want to add some options when a user presses the menu button, i

  • 0

i want to add some options when a user presses the menu button, i have tried the following but nothing seems to happen when i run the app and press the menu button:

the menu xml file

<?xml version="1.0" encoding="utf-8"?>
        <menu xmlns:android="http://schemas.android.com/apk/res/android">
         <item android:id="@+id/Map_view"
         android:title="@string/Map_view"
         android:icon="@drawable/satellite_view">
     <menu>
     <group android:checkableBehavior="single"
            android:id="@+id/menu_items">              
        <item android:id="@+id/satellite_view"
              android:icon="@drawable/satellite_view"
              android:title="@string/satellite_view"/>

        <item android:id="@+id/street_view"
              android:icon="@drawable/street_view"
              android:title="@string/street_view"/>
      </group>
     </menu>
  </item>              
</menu>

the MapAcitivity class

    package com.example.MyMapActivity;
    import java.util.List;
    import android.graphics.drawable.Drawable;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuInflater;
     import android.view.MenuItem;

    import com.google.android.maps.GeoPoint;
     import com.google.android.maps.MapActivity;
     import com.google.android.maps.MapController;
     import com.google.android.maps.MapView;
      import com.google.android.maps.Overlay;
     import com.google.android.maps.OverlayItem;

     public class MyMapActivity extends MapActivity {

    private MapView mapview;
    private MapController mapcontroller;
    private GeoPoint gp;


    //creating a class to for OverLays


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //setting the zoom controls
        mapview = (MapView)findViewById(R.id.mapview);
        mapview.setBuiltInZoomControls(true);
        mapview.setSatellite(true);


        List<Overlay>mapOverlays = mapview.getOverlays();
        // pass the drawable to instance of the OVerlay class.
        Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
        MyOverlay overlay = new MyOverlay(drawable,this);


       //setting a GeoPoint
        mapcontroller=mapview.getController();
        String coordinates[] = {"23.68855","86.97455"};
        double lat = Double.parseDouble(coordinates[0]);
        double longi = Double.parseDouble(coordinates[1]);
        gp = new GeoPoint((int)(lat*1E6), (int)(longi*1E6));

        OverlayItem overlayitem = new OverlayItem(gp, "Hello ", "I'm in Asansol");

        GeoPoint point2 = new GeoPoint(35410000, 139460000);
        OverlayItem overlayitem2 = new OverlayItem(point2, "Sekai, konichiwa!", "I'm in Japan!");


        overlay.addOverlay(overlayitem); //  call this method for each overlayitem 
        overlay.addOverlay(overlayitem2);
        mapOverlays.add(overlay);
        }
    // to inflate the menu defined in the map_menu xml file    
      public boolean OnCreateOptionsMenu(Menu menu)
      {
       MenuInflater  inflator = getMenuInflater();
       inflator.inflate(R.menu.map_menu, menu);
       return true;
     }

     public boolean OnOptionsItemSelected(MenuItem item)
     {
       switch(item.getItemId())
       {
       case R.id.satellite_view:
           if(item.isChecked())
           mapview.setSatellite(true);
           return true;
       case R.id.street_view:
           if(item.isChecked())
           mapview.setStreetView(true);
               return true;
        default:
            return super.onOptionsItemSelected(item);
       }
     }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        // this method must return true if your app returns driving directions , else return false
        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-15T23:38:59+00:00Added an answer on May 15, 2026 at 11:38 pm

    Short answer: onCreateOptionsMenu has to start with a lowercase o, not an uppercase O.

    Longer answer: In Java, method names always start with a lowercase letter (by convention, not because the Java compiler enforces it), and Android follows the convention faithfully. You intended to override Activity.onCreateOptionsMenu, but actually created a brand new method, MyMapActivity.OnCreateOptionsMenu. You’re allowed to create whatever methods you want, of course, so the compiler says nothing. Whenever you are intending to override a method from a superclass, you should mark it with @Override to tell the compiler that’s what you’re doing. If you do that to your current code, the compiler will complain that you claim to be overriding a method, but actually you’re not. Your IDE might even offer the corrected spelling as a suggestion. If you’re using Eclipse, you can even configure it to require the @Override annotation if you want to. I’m sure a quick SO search for “Java override” will turn up lots of similar questions, which may help you out.

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

Sidebar

Related Questions

I have a view that I want to add some custom drawing to. I
Suppose I have some application A with a database. Now I want to add
I have dbml with single table users i want add partial class for User
I want to add some logging capability to a cf.net application running on WM6
I want to add some Ajax -niceness to my Django-coded website. In my Django
I want to add a property to my User model that returns the number
I have some problems trying to custom the :path and :url options for has_attached_file
I want to add a column to an existing legacy database and write a
I want to add a constant value onto an incoming bound integer. In fact
I want to add a scheduled task to a client's ASP.NET app. These posts

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.