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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:07:13+00:00 2026-06-17T08:07:13+00:00

There is this widget for the ActionBar which called ‘SearchView’. When it’s not in

  • 0

There is this widget for the ActionBar which called ‘SearchView’.
When it’s not in use, it looks like this:

enter image description here

And when it’s in use, it looks like this:

enter image description here

I want (programmatically of course) to open the searchview (make it “in use”).

I tried several functions such as:

SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setOnQueryTextListener(this);

    searchView.performClick();
    searchView.requestFocus();

But none of those worked…

The SearchView in the XML:

<item android:id="@+id/menu_search"
      android:title="Search"
      android:icon="@drawable/ic_action_search"
      android:showAsAction="ifRoom|collapseActionView"
      android:actionViewClass="android.widget.SearchView" />
  • 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-17T08:07:13+00:00Added an answer on June 17, 2026 at 8:07 am

    Expand the SearchView with

    searchView.setIconified(false);
    

    and collapse it with

    searchView.setIconified(true);
    

    You need to change the value of android:showAsAction from ifRoom|collapseActionView to always. The SearchView‘s attribute android:iconifiedByDefault should be true, which is the default value, otherwise the user can not collapse the SearchView after it was expanded programmatically.

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

Sidebar

Related Questions

There's this already populated database which came from another dev. I'm not sure what
there's this interesting problem i can not solve myself. I will be very glad,
I want to use ember with a widget approach (component in isolation), setting rootElement
I have a widget which changes when an option is toggled. This invalidates all
There is this output of objdump on some object file: $ objdump -h main.o
There is this way, of course: OuterClass.this . But that's very clumsy. Ideally, there'd
There's this ... MSDN page, IQueryable(Of T) Interface . Can you do a better
there is this check-in-out program here at my workplace, it only takes the data
There was this problem that has been asked about implementing a load byte into
There's this very simple bit a code <asp:TextBox ID=txbVipNumber runat=server /> <asp:TextBoxWatermarkExtender ID=tbweVipNumber runat=server

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.