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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:32:23+00:00 2026-06-15T02:32:23+00:00

I am quite new to java android programming and I have a problem that

  • 0

I am quite new to java android programming and I have a problem that may be quite easy to answer, but I can’t figure what the eclipse compile error message implies.

The class runs fine except if I remove the block comment in the onContextItemSelected code below, I get this compile error:

The method onContextItemSelected(MenuItem) of type new View.OnCreateContextMenuListener(){} must override or implement a supertype method

What am I doing wrong or is missing here? Thanks.

Code

public class ListTest<registerForContextMenu> extends ListActivity  
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values));
        listView = getListView();

        // I populate the list view here

        listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

            @Override
            public void onCreateContextMenu(android.view.ContextMenu menu, View v, android.view.ContextMenu.ContextMenuInfo menuInfo) {
                menu.setHeaderIcon(R.drawable.ic_launcher);
                menu.setHeaderTitle(R.string.context_menu_options);
                menu.add(0, 0, 0, R.string.context_menu_reply);
                menu.add(0, 0, 0, R.string.context_menu_delete);
                menu.add(0, 0, 0, R.string.context_menu_cancel);
            };

            /*
            @Override
            public boolean onContextItemSelected(MenuItem item) {
                AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
                int index = info.position;
                return true;
            };
            */                      
       });
    }
}
  • 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-15T02:32:24+00:00Added an answer on June 15, 2026 at 2:32 am

    According to the documentation, onContextItemSelected is not a method of OnCreateContextMenuListener. That means that you cannot override it.

    onContextItemSelected is a method of Activity. Override it in your Activity.

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

Sidebar

Related Questions

I'm quite new to Android but already have some experience with Java itself. Now
I am quite new to Android dev, but not Java dev, so doing the
I'm quite new in Java android development. So I have an issue with my
I'm new to programming androids but I have quite a bit of experience programming
I'm still quite new to Android and Java programming and even newer to draw
So I am quite new to Android, and have limited previous Java experience, so
I am quite new to Java and am currently coding an Android application. In
First of all, I'm quite new to the Android and JAVA world (coming from
I'm beginning to work with Eclipse for some Java development. I'm quite new to
Ok, I'm quite stumped here. I'm getting an error, eclipse/android is saying that my

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.