简体   繁体   中英

SearchView does not inflate in actionbar

So this is what I have for my find_in_page.xml

<item android:id="@+id/find_text"
  android:title="@string/find_text"
      android:icon="@drawable/ab_search"
      android:showAsAction="ifRoom|collapseActionView"
      android:actionViewClass="android.support.v7.widget.SearchView" />

<item android:id="@+id/find_next"
      android:icon="@drawable/validation_arrow_inverted"
  android:showAsAction="always"
      android:title="@string/find_next"/>

<item android:id="@+id/find_prev"
      android:icon="@drawable/validation_arrow"
  android:showAsAction="always"
      android:title="@string/find_prev" />

And my code:

public boolean onCreateActionMode(ActionModeCompat mode, Menu menu) {
    mMenuInflater.inflate(R.menu.find_in_page_menu, menu)
}

Where mMenuInflater is an instance of android's menu inflater.

So the validation arrows come up fine but the searchview shows up in overflow menu and when I press it, it does not inflate.

How do I get the ab_search icon (its just a renamed magnifying glass icon) to show up in the menu and then expand to the text selection field?

Expand the SearchView with

searchView.setIconified(false);

and collapse it with

searchView.setIconified(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM