我正在使用SearchView在应用程序中提供搜索。 一切正常,除非我在可搜索的活动中并点击搜索按钮。
这是打开SearchableActivity确定(ok):
如果我单击搜索按钮以启动新搜索(不正常),会发生这种情况:
正如您可以看到ActionBar的样式更改(操作栏和建议下拉列表),它看起来像启用操作模式时,我不知道为什么会发生这种情况。
现在我单击向后或向上按钮,ActionBar将重置为初始样式(单击搜索按钮时应该得到什么):
任何帮助表示赞赏。 谢谢。
I am using SearchView to provide search in an application. Everything works fine, except when I'm in the searchable activity and click on the search button.
This is when opening the SearchableActivity (ok):
This is what happens if I click on the search button to initiate a new search (not ok):
As you can see the style of the ActionBar changes (both action bar and suggestion dropdown), it looks like when the action mode is enabled, and I don't have idea why this is happening.
And now I click back or up button, the ActionBar is reset to initial style (what should I get when clicking on the search button):
Any help is appreciated. Thank you.
最满意答案
这个问题是因为在SearchableActivity我拦截了搜索按钮并调用了onSearchRequested() :
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_search: onSearchRequested(); return true; default: return false; } }没有必要覆盖onOptionsItemSelected() ,删除这段代码解决了这个问题。
The issue was caused because in the SearchableActivity I was intercepting the search button and calling onSearchRequested():
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_search: onSearchRequested(); return true; default: return false; } }There's no need for onOptionsItemSelected() to be overrided, deleteting this piece of code solved the issue.
更多推荐
发布评论