Example usage for android.app SearchManager getSearchableInfo

List of usage examples for android.app SearchManager getSearchableInfo

Introduction

In this page you can find the example usage for android.app SearchManager getSearchableInfo.

Prototype

public SearchableInfo getSearchableInfo(ComponentName componentName) 

Source Link

Document

Gets information about a searchable activity.

Usage

From source file:im.vector.activity.LanguagePickerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_languages_picker, menu);
    CommonActivityUtils.tintMenuIcons(menu,
            ThemeUtils.getColor(this, R.attr.icon_tint_on_dark_action_bar_color));

    final MenuItem searchItem = menu.findItem(R.id.action_search);
    if (searchItem != null) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        mSearchView.setMaxWidth(Integer.MAX_VALUE);
        mSearchView.setSubmitButtonEnabled(false);
        mSearchView.setQueryHint(getString(R.string.search_hint));
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setOnQueryTextListener(this);
        SearchView.SearchAutoComplete searchAutoComplete = mSearchView
                .findViewById(android.support.v7.appcompat.R.id.search_src_text);
        searchAutoComplete.setHintTextColor(ThemeUtils.getColor(this, R.attr.default_text_hint_color));
    }//from   ww w .ja v a2s . c o  m
    return true;
}

From source file:org.melky.geekjuniorapp.GeekJunior.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.

    //Opcion de configuracion sobre la actividad principal
    //getMenuInflater().inflate(R.menu.menu_geek_junior, menu);
    //return true;

    if (!mNavigationDrawerFragment.isDrawerOpen()) {
        // Only show items in the action bar relevant to this screen
        // if the drawer is not showing. Otherwise, let the drawer
        // decide what to show in the action bar.
        getMenuInflater().inflate(R.menu.menu_geek_junior, menu);
        MenuItem searchItem = menu.findItem(R.id.action_example);

        searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

        SearchManager searchManager = (SearchManager) getSystemService(getApplicationContext().SEARCH_SERVICE);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

        MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {
            @Override/*from www.  j  av a2  s . c o  m*/
            public boolean onMenuItemActionExpand(MenuItem item) {
                return true;
            }

            @Override
            public boolean onMenuItemActionCollapse(MenuItem item) {
                onBackPressed();
                return true;
            }
        });

        restoreActionBar();
        return true;
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:im.neon.activity.CountryPickerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_country_picker, menu);

    final MenuItem searchItem = menu.findItem(R.id.action_search);
    if (searchItem != null) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        mSearchView.setMaxWidth(Integer.MAX_VALUE);
        mSearchView.setSubmitButtonEnabled(false);
        mSearchView.setQueryHint(getString(R.string.search_hint));
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setOnQueryTextListener(this);
    }/*from  w  w  w .j  av  a  2s .c o  m*/
    return true;
}

From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_category, menu);

    MenuItem searchItem = menu.findItem(R.id.menu_search_category);
    SearchView searchView = (SearchView) searchItem.getActionView();

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(//from  w  w  w  . j  av a  2  s. co m
            searchManager.getSearchableInfo(new ComponentName(getActivity(), MainActivity.class)));
    searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            final Cursor cursor = mCategoryDbAdapter.getAll();
            final int column = cursor.getColumnIndex(CategoryEntry.COLUMN_NAME);
            if (newText.length() > 0) {
                mCategoryAdapter.swapCursor(new FilterCursorWrapper(cursor, newText, column));

                if (mCategoryAdapter.getItemCount() == 0) {
                    String escapedNewText = TextUtils.htmlEncode(newText);
                    String formattedNoResults = String.format(getString(R.string.no_results_category),
                            escapedNewText);
                    CharSequence styledNoResults = Html.fromHtml(formattedNoResults);

                    mTextNoResultsCategory.setText(styledNoResults);
                    mTextNoResultsCategory.setVisibility(View.VISIBLE);
                } else {
                    mTextNoResultsCategory.setVisibility(View.GONE);
                }
            } else {
                mCategoryAdapter.swapCursor(cursor);
                mTextNoResultsCategory.setVisibility(View.GONE);
            }
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }
    });
}

From source file:com.zns.comicdroid.activity.Start.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.actionbar_start, (com.actionbarsherlock.view.Menu) menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mSearchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
        @Override/*from www .ja v  a 2  s  . c o m*/
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                String query = mSearchView.getQuery().toString();
                if (query.trim().length() == 0) {
                    mMenuSearch.collapseActionView();
                    BaseListFragment fragment = getCurrentFragment();
                    if (fragment != null) {
                        fragment.clearFilter();
                    }
                }
            }
        }
    });

    return true;
}

From source file:de.aw.monma.actions.FragmentWPList.java

/**
 * In der ActionBar die SearchView initialisieren
 *///  w  w w . ja  v a 2s  .c  o  m
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_wplist, menu);
    menu.findItem(R.id.menu_item_onlyBestand).setChecked(onlyBestand);
    menu.findItem(R.id.menu_item_sortieren).setChecked(sortieren);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_List_search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setOnQueryTextListener(this);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:koma.movieapp.ui.SearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.search, menu);
    final MenuItem searchItem = menu.findItem(R.id.menu_search);
    if (searchItem != null) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        final SearchView view = (SearchView) searchItem.getActionView();
        mSearchView = view;/*w w  w  . j ava  2 s  .  c o  m*/
        if (view == null) {
            LOGW(TAG, "Could not set up search view, view is null.");
        } else {
            view.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
            view.setIconified(false);
            view.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String s) {
                    view.clearFocus();
                    Bundle args = new Bundle();
                    args.putString("title", "Search");
                    args.putInt("queryType", Config.SEARCH_TOKEN);
                    args.putString("searchString", s);
                    mMoviesFragment.reloadFromArguments(args);
                    return true;
                }

                @Override
                public boolean onQueryTextChange(String s) {
                    //                        if (null != mMoviesFragment) {
                    //                            mMoviesFragment.requestQueryUpdate(s);
                    //                        }
                    return true;
                }
            });
            view.setOnCloseListener(new SearchView.OnCloseListener() {
                @Override
                public boolean onClose() {
                    finish();
                    return false;
                }
            });
        }

        if (!TextUtils.isEmpty(mQuery)) {
            view.setQuery(mQuery, false);
        }
    }
    return true;
}

From source file:com.kangsoo.pharmacy.fragment.IssuesFragment.java

@Override
public void onCreateOptionsMenu(Menu optionsMenu, MenuInflater inflater) {
    inflater.inflate(R.menu.issues, optionsMenu);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = optionsMenu.findItem(R.id.m_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));

    Bundle args = new Bundle();
    //kskim to-do
    args.putSerializable(EXTRA_REPOSITORY, shoppingCategory);
    searchView.setAppSearchData(args);/*  w ww .jav a 2  s  . c  om*/
}

From source file:com.ferid.app.frequentcontacts.selectnumber.SelectNumberActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.ic_action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//w w  w  . j a v a 2  s.  c  om
        public boolean onQueryTextSubmit(String s) {
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            if (s.length() >= 1)
                searchEngine(s);
            else {
                numberList.clear();
                numberList.addAll(wholeArrayList);
                adapter.notifyDataSetChanged();
            }
            return true;
        }
    });

    return true;
}

From source file:com.google.android.apps.iosched.ui.tablet.SessionsVendorsMultiPaneActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getSupportMenuInflater().inflate(R.menu.search, menu);
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    if (searchItem != null && UIUtils.hasHoneycomb()) {
        SearchView searchView = (SearchView) searchItem.getActionView();
        if (searchView != null) {
            SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
            searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        }// w w  w.  j av a 2  s.  com
    }
    return true;
}