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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:26:19+00:00 2026-06-12T15:26:19+00:00

I have a collapsed search EditView menu within my Actionbar (ActionbarSherlock). When setShowAsAction method

  • 0

I have a collapsed search EditView menu within my Actionbar (ActionbarSherlock). When setShowAsAction method is set to SHOW_AS_ACTION_NEVER, the keyboard displays and the user can start typing, as expected.

However when I set the value to SHOW_AS_ACTION_ALWAYS, the user has to touch the EditText before they start typing as it doesn’t appear to have focus!

Is there something wrong with my code or a way to work around this problem?

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    final MenuItem search = menu.add(0, MENU_SEARCH, MENU_SEARCH, getString(R.string.search));
    search.setIcon(R.drawable.ic_action_search);
    search.setActionView(R.layout.action_search);
    search.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case MENU_SEARCH:
            mSearch = (EditText) item.getActionView();
            mSearch.addTextChangedListener(mFilterTextWatcher);
            mSearch.requestFocus();
            mSearch.postDelayed(new Runnable() {
                @Override
                public void run() {
                    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                }
            }, 200);

            break;
    }
    return true;
}

action_search.xml

<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:singleLine="true"
          android:hint="@string/search" />
  • 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-12T15:26:20+00:00Added an answer on June 12, 2026 at 3:26 pm

    The solution was to nest the fragment within the Activity.

    public class ProductListActivity extends SherlockFragmentActivity {
        …
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
                ProductListFragment list = new ProductListFragment();
                getSupportFragmentManager().beginTransaction().add(android.R.id.content, list).commit();
            }
        }
    
        public static class ProductListFragment extends SherlockListFragment {
            …
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ActionBarSherlock, in the ActionBar i have this custom layout to appear
I have a dropdown menu which is expanded by clicking. The menu is collapsed
I have a CollapsiblePanelExtender that will not collapse. I have collapsed set to true
I have a Silverlight user control that is a textbox with a search button
I have an HTML table with collapsed and adjacent borders and a standard border
I have created a jquery plugin to expand/collapse ul,li something like a accordion menu
Ok so currently I have a ajax collapser for advance search options. Then I
I have a jQuery instant search bar on top of a data table. All
I have a search box at the top of my sidemenu. This search bar
I have a jqGrid that is using the toolbar search with some text searches

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.