如何彻底崩溃一个搜索查看后选择的项目? [英] How to completely collapse a SearchView after an item selected?

查看:115
本文介绍了如何彻底崩溃一个搜索查看后选择的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力奋斗着这个好几个星期。我有一个全球性的搜索,它提供了一个自定义列表视图与建议,作为一个用户类型。当用户选择一个选项,我想和SearchView返回到其完全收缩状态。

I've been struggling with this for weeks.. I have a global search that offers up a custom listview with suggestions as a user types. When a user selects an option, I want the searchview to return to its completely collapsed state.

相反,它逐渐缩​​小,但保持在一个稍微放大图。

Instead, it shrinks down but stays in a slightly expanded view.

我已经抛出一切,我可以在这件事情找到将其关闭,但不能为我的生命得到正确的方法。这里的功能:

I've thrown EVERYTHING I can find at this thing to close it, but cannot for the life of me get the right method. Here's the function:

    final SearchView.OnCloseListener closeListener = new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            return closeSearch();
        }
    };

    protected boolean closeSearch() {
    _searchView.clearFocus();
    _searchView.setQuery("", false);
    _searchView.setFocusable(false);
    _searchMenuItem.collapseActionView();
    isSearchFragmentVisible(false);
    return false;
}

当一个项目从定制的建议列表视图中选择关闭搜索,然后手动调用。

Close search is then manually called when an item is selected from the custom "suggestion" listview.

推荐答案

发现了它。该呼叫应 _searchView.onActionViewCollapsed()。为什么地球上你所谓的监听器​​式的方法(例如,一个与开始开),我是无法理解。

Found it. The call should be _searchView.onActionViewCollapsed(). Why on earth you call a "listener" style method (ie, one that begins with 'on') is beyond me.

这篇关于如何彻底崩溃一个搜索查看后选择的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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