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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:33:07+00:00 2026-06-15T06:33:07+00:00

I am trying to implement Action Bar using ActionBar Sherlock. I have three Action

  • 0

enter image description here

I am trying to implement Action Bar using ActionBar Sherlock. I have three Action Button one of which is a Search Button. On Clicking of the Search Button the Search input field should be displayed which i have already implemented. But i want it to take the full width of the Action Bar. Any idea how i can achieve the same.

  • 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-15T06:33:08+00:00Added an answer on June 15, 2026 at 6:33 am

    first make a editTextLayout

    layout_search.xml

    <?xml version="1.0" encoding="utf-8"?>
    <EditText xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/search_edit_text"
        android:cursorVisible="true"
        android:hint="@string/search_friend_hint"
        android:imeOptions="actionDone"
        android:inputType="text"
        android:textColor="@android:color/black"
        android:textCursorDrawable="@android:color/black" />
    

    In you menu xml add android:actionLayout and android:showAsAction="always|collapseActionView"
    for Search option.
    For other option make android:showAsAction="ifRoom"

    menu.xml

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    
        <item
            android:icon="@drawable/ic_action_sort"
            android:orderInCategory="1"
            android:showAsAction="ifRoom"
            android:title="@string/menu_sort"/>
        <item
            android:id="@+id/menu_search"
            android:actionLayout="@layout/layout_search"
            android:icon="@drawable/search"
            android:orderInCategory="0"
            android:showAsAction="always|collapseActionView"
            android:title="@string/search"/>
    
    </menu>
    

    in your activity or fragment override onCreateOptionsMenu like this
    fragment.java

    @Override
        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
            super.onCreateOptionsMenu(menu, inflater);
            inflater.inflate(R.menu.menu, menu);
    
            final EditText editText = (EditText) menu.findItem(
                    R.id.menu_search).getActionView();
            editText.addTextChangedListener(textWatcher);
    
            MenuItem menuItem = menu.findItem(R.id.menu_search);
            menuItem.setOnActionExpandListener(new OnActionExpandListener() {
                @Override
                public boolean onMenuItemActionCollapse(MenuItem item) {
                    // Do something when collapsed
                    return true; // Return true to collapse action view
                }
    
                @Override
                public boolean onMenuItemActionExpand(MenuItem item) {
                    editText.clearFocus();
                    return true; // Return true to expand action view
                }
            });
        }
    

    and add textWatcherListener

    private TextWatcher textWatcher = new TextWatcher() {
    
            @Override
            public void onTextChanged(CharSequence s, int start, int before,
                    int count) {
    
                if (null != mAdapter) {
                    mAdapter.getFilter().filter(s);
                }
            }
    
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
                // TODO Auto-generated method stub
    
            }
    
            @Override
            public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub
    
            }
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I using action bar by sherlock. I'm trying to implement it into my app.
I'm trying to implement sherlock actionbar but i can't set the right theme in
Ok I have an app that implements tabs in the action bar using fragments.
I am trying to implement an action bar within an activity. Is it possible
I am trying to implement something like an action bar in android 2.2 .
I'm trying to implement a drop down list as navigation for the action bar
I'm trying to use the SherlockMapActivity to use the Sherlock action bar on a
I'm trying to implement an action bar in my app. I'm trying to do
So I'm trying to style the tabs of my Actionbar, which I've implemented using
As topic states I'm trying to implement swipable tabs using Fragments and ActionBar. I've

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.