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.einzig.ipst2.activities.PSListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_pslistactivity, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search_pslistactivity).getActionView();
    if (searchView != null) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setSubmitButtonEnabled(true);
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override/*w ww.  j  a  v  a 2s.  com*/
            public boolean onQueryTextChange(String newText) {
                if (TextUtils.isEmpty(newText)) {
                    ((ListItemAdapter_PS) listView.getAdapter()).resetData();
                } else {
                    ((ListItemAdapter_PS) listView.getAdapter()).getFilter().filter(newText);
                }
                return false;
            }

            @Override
            public boolean onQueryTextSubmit(String query) {
                return false;
            }
        });
    } else
        Logger.d("MENU ITEM ACTION VIEW FOR SEARCH IS NULL");

    return true;
}

From source file:org.freespanish.diccionario.fragments.search.SearchFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.search_menu, menu);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setMaxWidth(Integer.MAX_VALUE);
    this.menu = menu;

}

From source file:ua.org.gdg.devfest.iosched.ui.HomeActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override// ww  w .  j  a  v  a2  s .  co  m
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    mOptionsMenu = menu;
    getMenuInflater().inflate(R.menu.home, 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()));
            searchView.setQueryRefinementEnabled(true);
        }
    }
    return true;
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.SignBrowserFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    Log.d(TAG, "onCreateOptionsMenu " + hashCode());
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.options_sign_browser, menu);
    final MenuItem item = menu.findItem(R.id.action_toggle_starred);
    if (this.showStarredOnly) {
        item.setIcon(R.drawable.ic_sign_browser_grade_checked);
    } else {//  w w  w  . j av a 2  s  . com
        item.setIcon(R.drawable.ic_sign_browser_grade_no_stroke);
    }
    final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
}

From source file:com.conferenceengineer.android.iosched.ui.HomeActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/* www.  j ava 2 s. c  o  m*/
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    mOptionsMenu = menu;
    getMenuInflater().inflate(R.menu.home, 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()));
            searchView.setQueryRefinementEnabled(true);
        }
    }

    if (!getResources().getBoolean(R.bool.has_conference_feedback_enabled)) {
        menu.removeItem(R.id.menu_feedback);
    }

    return true;
}

From source file:com.wojtechnology.sunami.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);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.search).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setOnQueryTextListener(this);
    final SearchView sv = mSearchView;
    mSearchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
        @Override/*from   w  w  w .j  ava2s  .  c  o  m*/
        public void onFocusChange(View v, boolean hasFocus) {
            if (v == sv && hasFocus) {
                hideSong();
                mDrawerFragment.closeDrawer();
            } else if (v == sv && !hasFocus) {
                showSong();
            }
        }
    });

    return true;
}

From source file:com.sean.nanastudio.taoyuanstreetparking.MainActivity.java

private void setSearchView(Menu menu) {

    searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));

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

    RxSearchView.queryTextChanges(searchView).subscribe(charSequence -> {
        presenter.search(String.valueOf(charSequence));
    });/* w  w w. j a v a 2  s.  c  o m*/

    searchView.setOnQueryTextFocusChangeListener((view, b) -> {
        if (b)
            getFabLocation().hide();
        else
            getFabLocation().show();
    });
}

From source file:com.app_software.chromisstock.ProductListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_app, menu);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.product_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//from   ww w .  j  a v  a2s. c o  m
        public boolean onQueryTextSubmit(String query) {
            m_ListFragment.setSearch((query));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            m_ListFragment.setSearch((newText));
            return true;
        }
    });

    return super.onCreateOptionsMenu(menu);
}

From source file:com.skubit.comics.activities.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSubmitButtonEnabled(true);

    searchView//from  w  w  w .j  a v a  2s.  c  o m
            .setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class)));
    searchView.setQueryHint("Search Comics");
    searchView.setOnSearchClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //
        }
    });
    return true;
}

From source file:net.abcdroid.devfest12.ui.HomeActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupSearchMenuItem(Menu 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()));
        }//from w  w w .  j  ava  2 s. c  om
    }
}