使用搜索查看后复位操作栏 [英] Reset action bar after using SearchView

查看:121
本文介绍了使用搜索查看后复位操作栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用搜索查看部件,使搜索我的应用程序。在最初的点击搜索图标上时,搜索查看部件扩展到搜索栏和后退箭头旁边的应用程序图标显示。如果我点击应用程序图标的操作栏将恢复到初始状态(没有后退箭头)和搜索查看将恢复为图标。

I'm using SearchView widget to enable searching in my app. After the initial click on the search icon, the SearchView widget expands into the search field and the "back" arrow is shown next to the application icon. If I click the application icon the action bar reverts to the initial state (no "back" arrow) and the SearchView reverts back to icon.

现在的问题是:搜索执行的操作栏并没有改变后,恢复的唯一方法是点击应用程序图标或手机上的返回箭头。不好,因为我想要的操作栏到初始状态时,搜索完成。我试过 SearchView.setIconofied(真),但有2个问题:

Now the problem: after the search is executed the action bar doesn't change, the only way to revert is to click the application icon or phone's "back" arrow. Not good since I want the action bar go to the initial state when the search is done. I tried SearchView.setIconofied(true) but there are 2 problems:

  1. 在搜索图标出现在同一地点的编辑字段(最初它是在最右边)。
  2. 在操作栏仍显示返回箭头。

我想这个问题,我从普通导航模式偏离面临的结果。在我的情况下,一切都发生在同一活动内(搜索结果显示在承载操作栏上的同一个活动),因此,例如执行 Activity.finish()只是使应用程序退出。

I think the problem I'm facing results from deviating from the regular navigation pattern. In my case everything is happening inside the same activity (search results are displayed in the same activity that hosts the action bar), so for example executing Activity.finish() simply makes app exit.

我如何引发退一万步的动作吧?或者模拟点击应用程序图标?

How do I trigger "go back one step" of the action bar? Or simulate click on the application icon?

推荐答案

这听起来像你已经设置此作为一个菜单项可折叠动作视图。您可以致电<一个href="http://developer.android.com/reference/android/view/MenuItem.html#collapseActionView%28%29">collapseActionView()在该菜单项实例,把它送回来给其关闭状态。

It sounds like you've set this up as a collapsible action view on a MenuItem. You can call collapseActionView() on that MenuItem instance to send it back to its closed state.

这篇关于使用搜索查看后复位操作栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆