How do I open the SearchView programmatically?

后端 未结 8 1627
既然无缘
既然无缘 2020-12-02 09:19

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

\

8条回答
  •  眼角桃花
    2020-12-02 09:33

    Try to call expandActionView() on MenuItem, not onActionViewExpanded() on ActionView.

    It works for me.

    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    searchView = (SearchView) searchMenuItem.getActionView();
    searchMenuItem.expandActionView();
    

提交回复
热议问题