List of usage examples for android.content Context SEARCH_SERVICE
String SEARCH_SERVICE
To view the source code for android.content Context SEARCH_SERVICE.
Click Source Link
From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java
@Override public void fillActionBar(ActionBar actionBar, Menu menu) { _actionBar = actionBar;/*w w w . ja va 2 s .co m*/ _menu = menu; List<MBToolDefinition> tools = MBMetadataService.getInstance().getTools(); for (MBToolDefinition def : tools) { if (def.isPreConditionValid()) { String localizedTitle = MBLocalizationService.getInstance().getTextForKey(def.getTitle()); MenuItem menuItem = menu.add(Menu.NONE, def.getName().hashCode(), tools.indexOf(def), localizedTitle); Drawable image = null; if (def.getIcon() != null) { image = MBResourceService.getInstance().getImageByID(def.getIcon()); menuItem.setIcon(image); } MenuItemCompat.setShowAsAction(menuItem, getMenuItemActionFlags(def)); if ("REFRESH".equals(def.getType())) { _refreshToolDef = def; } else if ("SEARCH".equals(def.getType())) { final SearchView searchView = new SearchView(_context); searchView.setTag(def); searchView.setOnQueryTextFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { Object tag = v.getTag(); if (tag instanceof MBToolDefinition) { MBToolDefinition toolDef = (MBToolDefinition) tag; if (toolDef.getOutcomeName() != null) { handleOutcome(toolDef); } } } else { searchView.setIconified(true); } } }); changeSearchImage(image, searchView); SearchManager searchManager = (SearchManager) _context.getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo( searchManager.getSearchableInfo(MBViewManager.getInstance().getComponentName())); MenuItemCompat.setActionView(menuItem, searchView); } } } if (actionBar != null) { populateActionBar(actionBar); } }
From source file:org.openmrs.client.activities.FindPatientsActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from w w w.ja v a 2 s .co m public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.find_patients_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView findPatientView; mFindPatientMenuItem = menu.findItem(R.id.actionSearch); if (OpenMRS.getInstance().isRunningHoneycombVersionOrHigher()) { findPatientView = (SearchView) mFindPatientMenuItem.getActionView(); } else { findPatientView = (SearchView) MenuItemCompat.getActionView(mFindPatientMenuItem); } SearchableInfo info = searchManager.getSearchableInfo(getComponentName()); findPatientView.setSearchableInfo(info); return true; }
From source file:com.deliciousdroid.activity.FragmentBaseActivity.java
@TargetApi(11) public void setupSearch(Menu menu) { if (android.os.Build.VERSION.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(false); }// w w w. j av a 2 s . co m }
From source file:com.andrew.apollo.ui.activities.BaseActivity.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s . c o m*/ */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getMenuInflater().inflate(R.menu.search, menu); // Settings getMenuInflater().inflate(R.menu.activity_base, menu); // Theme the search icon mResources.setSearchIcon(menu); final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); // Add voice search final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); searchView.setSearchableInfo(searchableInfo); // Perform the search searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(final String query) { // Open the search activity NavUtils.openSearch(BaseActivity.this, query); return true; } @Override public boolean onQueryTextChange(final String newText) { // Nothing to do return false; } }); return super.onCreateOptionsMenu(menu); }
From source file:uk.ac.hutton.ics.buntata.activity.NodeCatalogActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { /* Inflate the menu */ MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.node_list_menu, menu); /* Find the search menu item */ final MenuItem searchItem = menu.findItem(R.id.action_search); /* Get the search manager */ SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); /* Get the actual search view */ final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); searchView.setMaxWidth(displayMetrics.widthPixels / 2); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryHint(getString(R.string.search_node_name_hint)); /* Listen to submit events */ searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*from ww w.ja v a 2 s .c om*/ public boolean onQueryTextSubmit(String query) { /* Trim leading and trailing spaces that some keyboards will add */ query = query.trim(); filter(query); searchView.clearFocus(); return false; } @Override public boolean onQueryTextChange(String s) { /* Close the search field when the search string is empty */ if (StringUtils.isEmpty(s)) { searchView.setIconified(true); searchView.clearFocus(); } return false; } }); searchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { filter(""); return false; } }); } return super.onCreateOptionsMenu(menu); }
From source file:com.phicdy.mycuration.ui.TopActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final MenuItem searchMenuItem = menu.findItem(R.id.search); searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override/* w w w. j a va 2s. c om*/ public void onFocusChange(View view, boolean queryTextFocused) { if (!queryTextFocused) { searchMenuItem.collapseActionView(); searchView.setQuery("", false); } } }); SearchView.SearchAutoComplete searchAutoComplete = (SearchView.SearchAutoComplete) searchView .findViewById(android.support.v7.appcompat.R.id.search_src_text); searchAutoComplete.setTextColor(getResources().getColor(R.color.text_primary)); searchAutoComplete.setHintTextColor(getResources().getColor(R.color.text_primary)); return true; }
From source file:com.saarang.samples.apps.iosched.ui.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(com.saarang.samples.apps.iosched.R.menu.search, menu); final MenuItem searchItem = menu.findItem(com.saarang.samples.apps.iosched.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 a v a 2 s .c om*/ if (view == null) { LogUtils.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(); if ("zzznotif".equals(s)) { (new ShowFeedbackNotificationAction()).run(SearchActivity.this, null); } return true; } @Override public boolean onQueryTextChange(String s) { if (null != mSessionsFragment) { mSessionsFragment.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: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.murati.oszk.audiobook.ui.BaseActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mMenu = menu;//from w w w .j a v a 2s.co m return true; }
From source file:org.openmrs.mobile.activities.FindPatientsActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from ww w .j av a2s . c o m public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.find_patients_menu, menu); mFindPatientMenuItem = menu.findItem(R.id.actionSearch); if (!OpenMRS.getInstance().getOnlineMode()) { mFindPatientMenuItem.setEnabled(false); mFindPatientMenuItem.getIcon().setAlpha(ApplicationConstants.DISABLED_ICON_ALPHA); } else { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView findPatientView; if (OpenMRS.getInstance().isRunningHoneycombVersionOrHigher()) { findPatientView = (SearchView) mFindPatientMenuItem.getActionView(); } else { findPatientView = (SearchView) MenuItemCompat.getActionView(mFindPatientMenuItem); } SearchableInfo info = searchManager.getSearchableInfo(getComponentName()); findPatientView.setSearchableInfo(info); } return true; }