Code example for SearchManager

Methods: getSearchableInfo

0
        // Get the SearchView and set the searchable configuration 
        SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
        mSearchView = (SearchView) searchItem.getActionView();
        assert mSearchView != null;
        // Assumes current activity is the searchable activity 
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
        mSearchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
        mSearchView.setFocusable(false);
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        if (D) Log.d(LOG_TAG, "onOptionsItemSelected");
        int id = item.getItemId();
        // Клик по Refresh работает с ImageView.onClick 
        if (id == R.id.menu_search) {
            if (D) Log.d(LOG_TAG, "Search btn!");
            return false; 
        } 
        if (D) Log.d(LOG_TAG, "super.onOptionsItemSelected");
        return super.onOptionsItemSelected(item);