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.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/* www.java 2 s .co m*/ 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:ru.besttuts.stockwidget.ui.SearchableQuoteActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.search_activity_actions, menu); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final MenuItem searchItem = menu.findItem(R.id.action_search); searchView = (SearchView) MenuItemCompat.getActionView(searchItem); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String arg0) { LOGD(TAG, "onQueryTextChange: " + arg0); // TODO Auto-generated method stub return false; }/* w ww. ja v a2s. c o m*/ public boolean onQueryTextSubmit(String arg0) { LOGD(TAG, "onQueryTextSubmit: " + arg0); // if (searchItem != null) { // searchItem.collapseActionView(); // } // MenuItemCompat.collapseActionView(searchItem); return false; } }); searchView.setOnCloseListener(new android.support.v7.widget.SearchView.OnCloseListener() { @Override public boolean onClose() { LOGD(TAG, "setOnCloseListener: onClose"); return false; } }); return super.onCreateOptionsMenu(menu); }
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/*ww w .ja va2 s. c om*/ 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:io.github.hidroh.materialistic.BaseListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (mIsMultiPane) { getMenuInflater().inflate(R.menu.menu_item, menu); }/*from www . java 2 s.co m*/ if (isSearchable()) { getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem menuSearch = menu.findItem(R.id.menu_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch); searchView.setSearchableInfo( searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class))); searchView.setIconified(true); searchView.setQuery("", false); } return super.onCreateOptionsMenu(menu); }
From source file:ch.citux.td.ui.TDActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); refreshItem = menu.findItem(R.id.menu_refresh); searchItem = menu.findItem(R.id.menu_search); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextFocusChangeListener(this); return true;/*from ww w . ja v a 2s . c o m*/ }
From source file:ua.boberproduction.bbr.BaseActivity.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.action_search); SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE); searchView = null;/*w w w. j a v a 2 s. co m*/ if (searchItem != null) { searchView = (SearchView) searchItem.getActionView(); } if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(this.getComponentName())); searchView.setIconified(true); searchView.clearFocus(); searchView.onActionViewCollapsed(); } // if user activated God Mode, hide the 'remove ads' menu option.. if (Ad.getGodModeStatus(this)) { MenuItem item = menu.findItem(R.id.action_remove_ads); item.setVisible(false); } return super.onCreateOptionsMenu(menu); }
From source file:com.hangulo.powercontact.ContactsListFragment.java
void setupSearchView() { // Retrieves the system search manager service final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); // Retrieves the SearchView from the search menu item if (mSearchView == null) return;/* w ww .ja v a2 s.c o m*/ // Assign searchable info to SearchView mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); // mSearchView.setSubmitButtonEnabled(true); // enable subit button mSearchView.setIconifiedByDefault(false); mSearchView.setIconified(false); mSearchView.setFocusable(false); mSearchView.clearFocus(); // text focus ... mSearchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { if (!mTwoPane && !mCallback.isExpandedListViewFragment()) mCallback.launchSearchFragment(true); // ? . ? ? . } else { if (!mTwoPane & mCallback.isExpandedListViewFragment()) { mCallback.launchSearchFragment(false); // ? ? } } } }); // Set listeners for SearchView mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String queryText) { mSearchView.clearFocus(); if (!mTwoPane & mCallback.isExpandedListViewFragment()) { mCallback.launchSearchFragment(false); // ? ? } return true; } @Override public boolean onQueryTextChange(String newText) { // Called when the action bar search text has changed. Updates // the search filter, and restarts the loader to do a new query // using the new search string. // isSearchMode=true; // if first String starts with "@@Search:" then wait until input complete // ? @@Search: ... ? . // @@Search:198.20123232,-111.20232323 ? . // String newFilter = !TextUtils.isEmpty(newText) ? newText : null; // Don't do anything if the filter is empty if (mSearchKeyword == null && newFilter == null) { return true; } // Don't do anything if the new filter is the same as the current filter if (mSearchKeyword != null && mSearchKeyword.equals(newFilter)) { return true; } // Updates current filter to new filter // mPreviousSearchKeyword = mSearchKeyword; // ? ...... ? ? ?? ? . if (mSearchKeyword != null && mSearchKeyword.startsWith("@@")) // @@ , @@ ??... if (!mSearchKeyword.endsWith("@@")) return true; // ? . @@ ? . ? String search . mSearchKeyword = newFilter; // ...? ?. getActivity().getSupportLoaderManager().restartLoader(Constants.CONTACTLIST_LOADER, null, ContactsListFragment.this); return true; } }); }
From source file:be.brunoparmentier.openbikesharing.app.activities.StationsListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { this.optionsMenu = menu; getMenuInflater().inflate(R.menu.stations_list, menu); SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(manager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//from w ww . jav a 2s. c om public boolean onQueryTextSubmit(String s) { return false; } @Override public boolean onQueryTextChange(String s) { loadData(s); return true; } }); return true; }
From source file:de.uni_koblenz_landau.apow.PatientListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { mMenu = menu;/*from w w w . j a va2s.co m*/ getMenuInflater().inflate(R.menu.patient_list, menu); // Set up actionbar search. SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = (SearchView) menu.findItem(R.id.patient_list_action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextChange(String query) { if (!query.equals(mLastQuery)) { searchPatients(query, mReset); } mLastQuery = query; return true; } @Override public boolean onQueryTextSubmit(String query) { return false; } }); if (mSavedQuery.length() != 0) { mReset = false; MenuItem searchMenuItem = menu.findItem(R.id.patient_list_action_search); searchMenuItem.expandActionView(); searchView.setQuery(mSavedQuery, false); searchView.clearFocus(); } return super.onCreateOptionsMenu(menu); }
From source file:org.kontalk.ui.ConversationListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.conversation_list_menu, menu); // compose message /*//from w w w . j a v a 2 s. com MenuItem item = menu.findItem(R.id.menu_compose); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); */ // search mSearchMenu = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(mSearchMenu); SearchManager searchManager = (SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); // LayoutParams.MATCH_PARENT does not work, use a big value instead searchView.setMaxWidth(1000000); mDeleteAllMenu = menu.findItem(R.id.menu_delete_all); // offline mode mOfflineMenu = menu.findItem(R.id.menu_offline); // trigger manually onDatabaseChanged(); updateOffline(); }