以编程方式启动SearchView(Android)

以编程方式启动SearchView(Android),android,searchview,android-searchmanager,Android,Searchview,Android Searchmanager,我正在使用SearchView小部件执行搜索,其中包括查询和复选框中的一些其他信息 我遵循了使用SearchView小部件的方法,它工作得很好-但是因为我有额外的信息要添加到搜索中,我希望有一个FloatingActionButton触发搜索 到目前为止,我的代码用于设置搜索 private void setUpSearchCard(View layout) { // Retrieve SearchManager and the SearchView final SearchMa

我正在使用SearchView小部件执行搜索,其中包括查询和复选框中的一些其他信息

我遵循了使用SearchView小部件的方法,它工作得很好-但是因为我有额外的信息要添加到搜索中,我希望有一个FloatingActionButton触发搜索

到目前为止,我的代码用于设置搜索

private void setUpSearchCard(View layout) {
    // Retrieve SearchManager and the SearchView
    final SearchManager searchManager = (SearchManager) getContext()
            .getSystemService((Context.SEARCH_SERVICE));
    mSearchView = (SearchView) layout.findViewById(R.id.search_view);

    // Direct the SearchView to the activity that will get the result
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(
            new ComponentName(getContext(), SwipeDeckActivity.class)
    ));

    // Expand the bar by default
    mSearchView.setIconifiedByDefault(false);
}
我想添加到这个函数中的内容如下

    // Set up the search fab
    mSearchFAB = (FloatingActionButton) layout.findViewById(R.id.fab_search_button);
    mSearchFAB.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mSearchView.launchSearch();
        }
    });
我该怎么做?(显然应该发送插入的查询)


另外,我不想使用Android提供的在SearchView上弹出的按钮

只需尝试mSearchView.PerformClick()并试一试?我不确定是否只是尝试一下。不,它单击SearchView并将焦点设置为它,要启动它,您必须在SearchView上按“Enter”键:/如果我理解正确,您尝试的是搜索操作,而不是SearchView聚焦?@GeorgeThomas确切地说,我希望有一个类似“表单”的SearchView和复选框,然后我将按下我创建的晶圆厂并启动它。只需尝试mSearchView.PerformClick()并试一试?我不确定是否只是尝试一下。不,它单击SearchView并将焦点设置为它,要启动它,您必须在SearchView上按“Enter”键:/如果我理解正确,您尝试的是搜索操作,而不是SearchView聚焦?@GeorgeThomas确切地说,我希望有一个类似“表单”的SearchView和复选框,然后我会按我创建的晶圆厂并启动它。