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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:59:53+00:00 2026-06-03T03:59:53+00:00

I`m trying to request search from ActionBarSherlock. My class extends SherlockListActivity. This is how

  • 0

I`m trying to request search from ActionBarSherlock.

My class extends SherlockListActivity.

This is how I`m adding Menu button to the ActionBar:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add("Save")
            .setIcon(R.drawable.ic_action_search)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM |
                MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        return true;
    }

The problem is that I am unable to invoke it by id:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId())  {
            case ?????: {
                onSearchRequested();
                return true;
            }
        }
        return true;
    }

How people usually solve this problem?

Thanks.

  • 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-03T03:59:54+00:00Added an answer on June 3, 2026 at 3:59 am

    If you inflate you menu from an XML menu file you will set an id which you can then use in your onOptionsItemSelected method. Like this:

    XML

    <menu xmlns:android="http://schemas.android.com/apk/res/android">     
        <item android:id="@+id/menu_search"
        android:icon="@drawable/ic_menu_search"
        android:showAsAction="ifRoom"
        android:actionViewClass="android.widget.SearchView" android:title="@string/search"/>
    </menu>
    

    Fragment

     @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
    
            case R.id.menu_search:
                onSearchRequested();
    
                return true;
    
            default:
                return super.onOptionsItemSelected(item);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
I am trying to get the JSON data from a Twitter search request such
I'm trying to use Request.JSON in mooTools to bring in an object from a
Trying to honor a feature request from our customers, I'd like that my application,
I've been trying to Base64 encode image data from the user (in this case
Hi I am trying to retrieve news(Bing Search API) from a 1 of the
I am trying to use the Bing SOAP API for a simple search request.
I am trying to implement a search algorithm in my simple datastructure. However, this
I'm trying to open a webpage using urllib.request.urlopen() then search it with regular expressions,
I'm trying to programmatically extract some data from this url: http://www.treasurydirect.gov/NP/BPDLogin?application=np The issue is

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.