How do I close a SearchView programmatically?

后端 未结 13 1720
误落风尘
误落风尘 2020-12-23 19:10

I currently have a SearchView in the action bar of my app. When I click the search icon, the SearchView expands and the keyboard pops up as expecte

13条回答
  •  旧时难觅i
    2020-12-23 19:30

    if you have input on your searchView

    mSearchView.setIconified(true);
    

    will only clear the text.

    The correct method to close a searchView is

    mSearchView.onActionViewCollapsed();
    

提交回复
热议问题