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:com.example.android.materialdesigncodelab.ui.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//www .ja v a 2s. com
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (TextUtils.isEmpty(newText)) {
                mRecyclerView.setVisibility(View.GONE);
            } else {
                AmapUtils.inputTips(getApplicationContext(), newText, "", new Inputtips.InputtipsListener() {
                    @Override
                    public void onGetInputtips(List<Tip> list, int i) {
                        mContentAdapter.update(list);
                        mRecyclerView.setVisibility(View.VISIBLE);
                    }
                });
            }
            return false;
        }
    });
    return true;
}

From source file:gdg.androidtitlan.spotifymvp.example.ui.fragment.ArtistsFragment.java

private void setupSearchView(Menu menu) {
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setMaxWidth(toolbar.getWidth());
    searchView.setOnQueryTextListener(this);
}

From source file:com.twinone.locker.ui.AppsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.apps, menu);
    mMenu = menu;/* w  w w . j  a va  2 s .  co m*/
    updateMenuLayout();

    // MenuItem mi = menu.findItem(R.id.apps_menu_search);
    // EditText test = (EditText) MenuItemCompat.getActionView(mi);

    SearchManager sm = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    MenuItem mi = (MenuItem) menu.findItem(R.id.apps_menu_search);
    SearchView sv = (SearchView) MenuItemCompat.getActionView(mi);
    sv.setSearchableInfo(sm.getSearchableInfo(getActivity().getComponentName()));

}

From source file:com.github.pockethub.android.ui.search.SearchActivity.java

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

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

    return true;/* ww w  . j a  v a  2  s  .  c  o  m*/
}

From source file:com.github.pockethub.ui.search.SearchActivity.java

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

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

    return true;// www .  j a va2 s  .  c o m
}

From source file:com.jackie.searchFunction.MainActivity.java

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

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    MenuItem menuItem = menu.findItem(R.id.action_search);
    if (SDKUtils.IS_HONEYCOMB) {
        android.widget.SearchView searchView = (android.widget.SearchView) menuItem.getActionView();
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    } else {//from w ww  .  j  a  v a  2 s .  c o m
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }

    return true;
}

From source file:org.epstudios.epcoding.ProcedureListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.shortmenu, menu);
    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    Log.d("EPCODING", getComponentName().toString());
    searchView.setIconifiedByDefault(false); // Do not iconify the widget;
    //   expand it by default

    return super.onCreateOptionsMenu(menu);
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

private void setupSearchView() {
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setIconified(false);/*from   w  w w  .ja  v  a2  s .c  om*/
    // Set the query hint.
    mSearchView.setQueryHint(getString(R.string.search_hint));
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String s) {
            mSearchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            searchFor(s);
            return true;
        }
    });
    mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            dismiss(null);
            return false;
        }
    });
    if (!TextUtils.isEmpty(mQuery)) {
        mSearchView.setQuery(mQuery, false);
    }
}

From source file:de.aw.monma.wertpapier.FragmentWertpapierBuchungenListe.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_wp_buchungen, menu);
    if (mWPID == NOID) {
        // SearchView nur zeigen, wenn nicht auf ein WP eingeschraenkt
        MenuItem item = menu.findItem(R.id.menu_List_search);
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
        SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
        searchView.setOnQueryTextListener(this);
        item.setVisible(true);//w w w  .  j  a  va 2 s  .c  om
    }
}

From source file:org.apache.taverna.mobile.ui.favouriteworkflow.FavouriteWorkflowsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setSubmitButtonEnabled(false);
    searchView.setOnQueryTextListener(this);
    searchView.setOnCloseListener(this);
}