android pass bundle with search

后端 未结 5 1832
南笙
南笙 2020-12-06 13:02

Hello i am using android 3.0 search widget(not the search mode), the problem is i need to pass some parameters along with the search word.

Android i

5条回答
  •  温柔的废话
    2020-12-06 13:16

    when querying by searchview ( searchable || searchview widget ) you can pass parameter to searchActivity ( searchResultActivity ) by define your own OnQueryTextListener like this.

    searchView.setOnQueryTextListener(new OnQueryTextListener() {
    
            @Override
            public boolean onQueryTextChange(String arg0) {
                // TODO Auto-generated method stub
                return false;
            }
    
            @Override
            public boolean onQueryTextSubmit(String query) {
                Intent searchIntent = new Intent(getApplicationContext(), SearchResultsActivity.class);
                searchIntent.putExtra(SearchManager.QUERY, query);
                searchIntent.setAction(Intent.ACTION_SEARCH);
                startActivity(searchIntent);
                return true;
            }
        });
    

提交回复
热议问题