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.sage42.androidappaddicts.app.main.MainActivity.java
@OptionsItem(R.id.action_search) public void initSearchView(final MenuItem item) { final SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE); this.mSearchViewMenuItem = item; this.mSearchView = (SearchView) this.mSearchViewMenuItem.getActionView(); this.mSearchView.setSearchableInfo(searchManager.getSearchableInfo(this.getComponentName())); this.mSearchView.setIconifiedByDefault(true); this.setSearchTextColour(this.mSearchView); this.mSearchView.setQueryHint("Search Apps"); //$NON-NLS-1$ this.mSearchView.setSuggestionsAdapter(this.mAdapter); this.mSearchViewMenuItem.setOnActionExpandListener(new OnActionExpandListener() { @Override/*from ww w .j av a 2s . c o m*/ public boolean onMenuItemActionCollapse(final MenuItem menuItem) { MainActivity.this.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); MainActivity.this.mSearchResult.setVisibility(View.GONE); return true; } @Override public boolean onMenuItemActionExpand(final MenuItem menuItem) { MainActivity.this.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); MainActivity.this.mSearchResult.setVisibility(View.VISIBLE); return true; } }); }
From source file:io.github.hidroh.materialistic.FavoriteFragment.java
private void createSearchView(MenuItem menuSearch) { final SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch); searchView.setQueryHint(getString(R.string.hint_search_saved_stories)); searchView.setSearchableInfo(((SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE)) .getSearchableInfo(getActivity().getComponentName())); searchView.setIconified(!mSearchViewExpanded); searchView.setQuery(mFilter, false); searchView.setOnSearchClickListener(v -> { mSearchViewExpanded = true;//from www.ja va2s . c o m v.requestFocus(); }); searchView.setOnCloseListener(() -> { // trigger a dummy empty search intent, as empty query does not get submitted searchView.setQuery(FavoriteActivity.EMPTY_QUERY, true); return false; }); }
From source file:github.popeen.dsub.fragments.SubsonicFragment.java
protected void onFinishSetupOptionsMenu(final Menu menu) { searchItem = menu.findItem(R.id.menu_global_search); if (searchItem != null) { searchView = (SearchView) MenuItemCompat.getActionView(searchItem); SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); SearchableInfo searchableInfo = searchManager.getSearchableInfo(context.getComponentName()); if (searchableInfo == null) { Log.w(TAG, "Failed to get SearchableInfo"); } else {/* w ww .j a v a 2 s . c o m*/ searchView.setSearchableInfo(searchableInfo); } String currentQuery = getCurrentQuery(); if (currentQuery != null) { searchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchView.setQuery(getCurrentQuery(), false); } }); } } }
From source file:com.numenta.taurus.instance.InstanceListActivity.java
private void configureSearchView(@NonNull final SearchView searchView) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // Handle query events searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//from ww w . j a va2 s . c o m public boolean onQueryTextSubmit(String query) { // Hide Keyboard on submit InputMethodManager imm = (InputMethodManager) searchView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0); } return true; } @Override public boolean onQueryTextChange(String newText) { // Filter list as the user types _listFragment.applyFilter(newText); return true; } }); // FIXME: Android does not support styling the search view across all versions. // For now, "peek" into internal API to make the appropriate changes to the SearchView. // In the future we should use the official android API to customize the SearchView widget. // See android.R.layout.search_view for the layout we are "peeking". It is no guarantee it // will work on all public android versions and/or OEM customizations. // This HACK is only valid for the POC phase. We should find a better solution before releasing Resources resources = searchView.getResources(); // Style search box and text int searchPlateId = resources.getIdentifier("android:id/search_plate", null, null); View searchPlate = searchView.findViewById(searchPlateId); if (searchPlate != null) { int searchTextId = resources.getIdentifier("android:id/search_src_text", null, null); TextView searchText = (TextView) searchPlate.findViewById(searchTextId); if (searchText != null) { searchPlate.setBackgroundResource(android.R.drawable.editbox_background); searchText.setPadding(5, 0, 0, 0); searchText.setTextColor(Color.BLACK); searchText.setHintTextColor(Color.LTGRAY); } } }
From source file:com.misczak.joinmybridge.PhoneBookFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.fragment_phonebook, menu); searchItem = menu.findItem(R.id.menu_item_search); searchView = (SearchView) searchItem.getActionView(); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); ComponentName name = getActivity().getComponentName(); SearchableInfo searchInfo = searchManager.getSearchableInfo(name); searchView.setSearchableInfo(searchInfo); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//ww w. j a v a2s. c o m public boolean onQueryTextSubmit(String s) { return false; } @Override public boolean onQueryTextChange(String s) { filterString = s; adapter.getFilter().filter(s); return true; } }); searchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { adapter.notifyDataSetChanged(); return 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 ava 2 s. co m*/ } }
From source file:uk.ac.horizon.artcodes.activity.NavigationActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.search_menu, menu); final MenuItem searchItem = menu.findItem(R.id.search); final SearchView searchView = (SearchView) searchItem.getActionView(); final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { private Runnable delayedAction = null; @Override/*from w ww . ja v a 2s .c o m*/ public boolean onQueryTextSubmit(String query) { search(query); return true; } @Override public boolean onQueryTextChange(final String newText) { if (delayedAction != null) { searchHandler.removeCallbacks(delayedAction); delayedAction = null; } if (newText.trim().length() > 3) { delayedAction = new Runnable() { @Override public void run() { search(newText); } }; searchHandler.postDelayed(delayedAction, 1000); } return true; } }); MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(final MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(final MenuItem item) { Log.i("a", "Closed"); Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG); if (fragment instanceof ExperienceSearchFragment) { getSupportFragmentManager().popBackStack(); } return true; } }); return true; }
From source file:com.inmovilizaciones.activity.ListarInmovilizacionesActivity.java
public void configurarBuscador(Menu menu) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.menu_buscar); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { public boolean onQueryTextSubmit(String query) { realizarBusqueda(query);//from ww w . j ava 2s .c o m return true; } public boolean onQueryTextChange(final String s) { return false; } }); }
From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java
/** * {@inheritDoc}//from ww w . j av a2s. c o m */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getSupportMenuInflater().inflate(R.menu.search, 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(AudioPlayerActivity.this, query); return true; } @Override public boolean onQueryTextChange(final String newText) { // Nothing to do return false; } }); // Favorite action getSupportMenuInflater().inflate(R.menu.favorite, menu); // Shuffle all getSupportMenuInflater().inflate(R.menu.shuffle, menu); // Share, ringtone, and equalizer getSupportMenuInflater().inflate(R.menu.audio_player, menu); // Settings getSupportMenuInflater().inflate(R.menu.activity_base, menu); return true; }
From source file:au.com.cybersearch2.classyfy.MainActivity.java
/** * Create search view SearchableInfo (xml/searchable.xml) and IconifiedByDefault (false) * @param menu Menu object/*from w w w. j ava 2 s .c o m*/ */ protected void createSearchView(Menu menu) { /** Get the action view of the menu item whose id is action_search */ // Associate searchable configuration (in res/xml/searchable.xml with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchMenuItem = menu.findItem(R.id.action_search); if (searchMenuItem == null) throw new IllegalStateException("Search menu item not found in main menu"); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); if (searchView == null) throw new IllegalStateException("SearchView not found in main menu"); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default }