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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:02:48+00:00 2026-05-31T20:02:48+00:00

I know this question was asked previously and the reply was to override onPrepareContextMenu()/onCreateContextMenu().

  • 0

I know this question was asked previously and the reply was to override onPrepareContextMenu()/onCreateContextMenu(). But I didnt understand and didnt get any solution for it. Please help me how to disable the context menu for particular ListView items.

  • 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-31T20:02:50+00:00Added an answer on May 31, 2026 at 8:02 pm

    Opening your context menu depends on your some logic. For example, in method onItemClick (in your listView) you should check content of your item and show or don’t show context menu. I don’t understand, why it’s problem for you?

    UPDATE

    public class ExampleActivity extends ListActivity {
    
        private ListView mListView;
        private ArrayList<String> mList = new ArrayList<String>();
        private ArrayAdapter<String> mArrayAdapter;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            mArrayAdapter = new ArrayAdapter<String>(this, android.R.id.list ,mList);
            mListView = (ListView) findViewById(android.R.id.list);
            setListAdapter(mArrayAdapter);
            registerForContextMenu(mListView);
    
            mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
    
                @Override
                public boolean onItemLongClick(AdapterView<?> adapterView , View v,int position, long id) {
                    mListView.getItemAtPosition(position); //check current item with your logic and show or don't show contextMenu
                    // for example I will show
                    mListView.showContextMenu(); //to show
                    return true;
                }
            });
        }
    
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            // add contextmenu items
            super.onCreateContextMenu(menu, v, menuInfo);
        }
    
        @Override
        public boolean onContextItemSelected(MenuItem item) {
            // todo some logic...
            return super.onContextItemSelected(item);
        }
    

    }

    May be it will help you… good luck…

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

Sidebar

Related Questions

I asked a question related to this one previously but I need to know
I know this question has been asked previously, but they were asked a long
I know that this question is being asked before but I did not get
I know this question has been asked before, but I ran into a problem.
I know this question has been asked a bit before. But looking around I
I know this exact question was asked here , but the answer didn't work
I know this specific question has been asked before , but I am not
I know a question like this was already asked, but the situation is a
UPDATE 10/19/2010 I know I asked this question a while ago, but the workarounds
I know this question has been asked before, but none of the previous answers

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.