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.svpino.longhorn.fragments.StockListFragment.java
@TargetApi(14) @Override//from w w w .j a va 2 s . c om public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_stock_list, menu); this.searchMenuItem = menu.findItem(R.id.menu_item_add); if (isIceCreamSandwichOrLater()) { SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); this.searchView = (SearchView) this.searchMenuItem.getActionView(); this.searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); this.searchView.setSubmitButtonEnabled(false); this.searchView.setIconifiedByDefault(true); final ShareActionProvider shareActionProvider = (ShareActionProvider) menu .findItem(R.id.menu_item_share).getActionProvider(); shareActionProvider.setShareIntent(getDefaultShareIntent(null)); shareActionProvider.setOnShareTargetSelectedListener(new OnShareTargetSelectedListener() { @Override public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { Intent defaultShareIntent = getDefaultShareIntent(null); shareActionProvider.setShareIntent(defaultShareIntent); return false; } }); } super.onCreateOptionsMenu(menu, inflater); }
From source file:com.tct.mail.ui.ActionBarController.java
public boolean onCreateOptionsMenu(Menu menu) { mEmptyTrashItem = menu.findItem(R.id.empty_trash); mEmptySpamItem = menu.findItem(R.id.empty_spam); mSearch = menu.findItem(R.id.search); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-S mStarSwitch = menu.findItem(R.id.menu_star_toggle); if (mStarSwitch != null) { mSwitch = (Switch) mStarSwitch.getActionView().findViewById(R.id.star_toggle); mSwitch.setOnCheckedChangeListener(mController); }/*from w ww . j a v a 2 s .c o m*/ //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-E if (mSearch != null) { mSearchWidget = (SearchView) MenuItemCompat.getActionView(mSearch); MenuItemCompat.setOnActionExpandListener(mSearch, this); SearchManager searchManager = (SearchManager) mActivity.getActivityContext() .getSystemService(Context.SEARCH_SERVICE); if (searchManager != null && mSearchWidget != null) { SearchableInfo info = searchManager.getSearchableInfo(mActivity.getComponentName()); /// TCT: The SearchableInfo may be customized by Email, and we need checking its validation. final String authority = getContext().getString(R.string.suggestions_authority); if (info != null && authority.equals(info.getSuggestAuthority())) { mSearchWidget.setSearchableInfo(info); mSearchWidget.setOnSuggestionListener(this); } //TS: Gantao 2016-01-25 EMAIL BUGFIX-1489887 ADD-S //Set focusable false in case always show the search suggestion mSearchWidget.setFocusable(false); //TS: Gantao 2016-01-25 EMAIL BUGFIX-1489887 ADD-E mSearchWidget.setOnQueryTextListener(this); // mSearchWidget.setOnSuggestionListener(this); mSearchWidget.setIconifiedByDefault(true); } } //[FEATURE]-Add-BEGIN by CDTS.zhonghua.tuo,05/21/2014,FR 670064 mLocalSearchItem = menu.findItem(R.id.local_search); mServiceSearchItem = menu.findItem(R.id.service_search); //[FEATURE]-Add-END by CDTS.zhonghua.tuo // the menu should be displayed if the mode is known return getMode() != ViewMode.UNKNOWN; }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.BusStopMapFragment.java
/** * {@inheritDoc}//from ww w. j a v a 2 s .c om */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Retain the instance to this Fragment. setRetainInstance(true); final Context context = getActivity(); bsd = BusStopDatabase.getInstance(context.getApplicationContext()); sp = context.getSharedPreferences(PreferencesActivity.PREF_FILE, 0); searchMan = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); services = bsd.getBusServiceList(); if (savedInstanceState != null) { chosenServices = savedInstanceState.getStringArray(ARG_CHOSEN_SERVICES); } // Get the height of the ActionBar from the assigned attribute in the // appcompat project theme. final TypedValue value = new TypedValue(); getActivity().getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, value, true); actionBarHeight = getResources().getDimensionPixelSize(value.resourceId); // This Fragment shows an options menu. setHasOptionsMenu(true); }
From source file:com.peaceworld.wikisms.view.newui.BaseActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void handleSearchForSdkAbove11() { MenuItem menuItem = menu.findItem(R.id.search); menuItem.setVisible(false);//from www . j a v a2 s . c o m SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView search = (SearchView) menu.findItem(R.id.menu_search).getActionView(); search.setSearchableInfo(manager.getSearchableInfo(getComponentName())); search.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextChange(String query) { loadData(query); return true; } @Override public boolean onQueryTextSubmit(String arg0) { return false; } }); }
From source file:com.paranoid.gerrit.GerritControllerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.gerrit_instances_menu, menu); this.mMenu = menu; // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); // Let the change list fragment handle queries directly. searchView.setOnQueryTextListener(mChangeList); searchView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override/*from ww w. jav a2 s . com*/ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { SearchView view = (SearchView) v; if (view.isIconified()) { mMenu.findItem(R.id.menu_team_instance).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.findItem(R.id.menu_projects).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } else { mMenu.findItem(R.id.menu_team_instance).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mMenu.findItem(R.id.menu_projects).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } }); setupSearchQuery(); return true; }
From source file:com.boko.vimusic.ui.activities.AudioPlayerActivity.java
/** * {@inheritDoc}/* w w w .ja v a 2 s .c o m*/ */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getMenuInflater().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 getMenuInflater().inflate(R.menu.favorite, menu); // Shuffle all getMenuInflater().inflate(R.menu.shuffle, menu); // Share, ringtone, and equalizer getMenuInflater().inflate(R.menu.audio_player, menu); // Settings getMenuInflater().inflate(R.menu.activity_base, menu); return true; }
From source file:ru.lizaalert.common.ui.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the options menu from XML MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.yp_menu, menu); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem item = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) item.getActionView(); // Assumes current activity is the searchable activity assert searchView != null; assert searchManager != null; searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // searchView.setIconifiedByDefault(false); return true;//from w w w . ja v a2 s . c o m }
From source file:osu.appclub.corvallisbus.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); assert searchManager != null; searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnQueryTextListener(this); searchView.setSubmitButtonEnabled(false); searchView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override/* w w w .j a v a2s . c om*/ public void onFocusChange(View v, boolean hasFocus) { Log.d("osu.appclub", "Focus changed to " + hasFocus); } }); return true; }
From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.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.poi_map, menu); miSearch = menu.findItem(R.id.action_search); miDirections = menu.findItem(R.id.action_directions); miPlay = menu.findItem(R.id.action_play); String[] poiNames = new String[gmm.pois.size()]; for (int i = 0; i < gmm.pois.size(); i++) { poiNames[i] = gmm.pois.get(i).getName(); }//from www.ja va2 s . c om searchView = (ArrayAdapterSearchView) (SearchView) MenuItemCompat.getActionView(miSearch); mAdapter = new ArrayAdapter<String>(this, R.layout.dropdown_item, poiNames); searchView.setAdapter(mAdapter); searchView.setThreshold(1); // one letter is enough for auto complete searchView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // when clicked on suggested item SearchModule.searchGoogleMap(POIMapActivity.this, gmm.googleMap, gmm.pois, searchView, mAdapter.getItem(position).toString()); MenuItemCompat.collapseActionView(miSearch); } }); searchView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // when clicked on search view (e.g. search icon) searchView.showDropDown(); } }); searchView.setQueryHint(POIMapActivity.this.getResources().getString(R.string.search_hint)); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); if (null != searchView) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); } SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String newText) { // some action if needed return true; } public boolean onQueryTextSubmit(String query) { // get entered query value and search SearchModule.searchGoogleMap(POIMapActivity.this, gmm.googleMap, gmm.pois, searchView, query); MenuItemCompat.collapseActionView(miSearch); return true; } }; searchView.setOnQueryTextListener(queryTextListener); return super.onCreateOptionsMenu(menu); // return true; }
From source file:com.racoon.ampdroid.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.main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return true;/*ww w. ja v a 2 s .co m*/ }