List of usage examples for android.app SearchManager getSearchableInfo
public SearchableInfo getSearchableInfo(ComponentName componentName)
From source file:com.pindroid.activity.FragmentBaseActivity.java
public void setupSearch(Menu menu) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { public boolean onQueryTextSubmit(String query) { startSearch(query);//w ww .j a va2 s . co m return true; } public boolean onQueryTextChange(final String s) { return false; } }); }
From source file:systems.soapbox.ombuds.client.ui.omb.SearchActivity.java
private void setupSearchView() { SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setIconified(false);/*from w ww .j a v a2s . co m*/ // Set the query hint. mSearchView.setQueryHint(getString(R.string.search_input_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:com.google.android.apps.mytracks.util.Api11Adapter.java
@Override public void configureSearchWidget(Activity activity, final MenuItem menuItem) { SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menuItem.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); searchView.setQueryRefinementEnabled(true); }
From source file:no.group09.ucsoftwarestore.MainFragmentActivity.java
/** * Creates options menu//from w ww. ja v a2 s . c om */ @SuppressLint("NewApi") @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_menu, menu); //When the menu is created, check the preferences and set the correct text if (sharedPref.getBoolean("hide_incompatible", false)) { menu.getItem(1).setTitle("Hide incompatible"); menu.getItem(1).setChecked(true); } else { menu.getItem(1).setTitle("Hide incompatible"); menu.getItem(1).setChecked(false); } //Search bar for versions over API level 11 int SDK_INT = android.os.Build.VERSION.SDK_INT; if (SDK_INT >= 11) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(true); } return true; }
From source file:org.bwgz.quotation.activity.SearchResultsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu)); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); Intent intent = getIntent();/*from w w w . jav a 2 s .c o m*/ if (intent != null) { int type = intent.getIntExtra(EXTRA_SEARCH_TYPE, FreebaseSearch.SEARCH_TYPE_KEYWORD); Log.d(TAG, String.format("onCreateOptionsMenu - type: %s", type)); setSearchHint(menu, type); String query = intent.getStringExtra(SearchManager.QUERY); Log.d(TAG, String.format("onCreateOptionsMenu - query: %s", query)); if (query != null) { searchView.setIconified(true); searchView.setQuery(query, false); searchView.clearFocus(); } } return true; }
From source file:org.yuzhiqiang.itsmine.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { 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.main, menu); restoreActionBar();/*from w ww. j av a 2 s. c o m*/ // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default return true; } return super.onCreateOptionsMenu(menu); }
From source file:dev.vision.shopping.center.Fragments.GourmetFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { //inflater.inflate(R.menu.main, menu); inflater.inflate(R.menu.offers, menu); MenuItem searchItem = menu.findItem(R.id.action_search); MenuItem expand = menu.findItem(R.id.expand); expand.setVisible(false);//from w ww.j a v a 2 s. c om SearchView searchView = null; searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView == null) searchView = (SearchView) searchItem.getActionView(); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); searchView.setOnQueryTextListener(this); }
From source file:asu.edu.msse.gpeddabu.moviedescriptions.AddMovie.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.movie_search_menu, menu); // setup the search in action bar // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = (android.widget.SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextListener(this); return true;//from ww w .ja va 2 s . c o m }
From source file:com.lucassaka.botonerags.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); MenuItem searchItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); // Assumes current activity is the searchable activity searchView.setSearchableInfo(/* ww w . j a v a 2 s . co m*/ searchManager.getSearchableInfo(new ComponentName(this, SearchableActivity.class))); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default return true; }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.HomeActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from www.j a v a 2 s . c om 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; }