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.hartcode.hartweather.list.WeatherListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_weather_list, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); this.searchMenuItem = menu.findItem(R.id.action_add); this.searchView = (SearchView) searchMenuItem.getActionView(); this.searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); this.searchView.setIconifiedByDefault(true); MenuItemCompat.setOnActionExpandListener(this.searchMenuItem, this); if (this.isSearchShown) { this.searchMenuItem.expandActionView(); }// ww w. j a v a 2 s . c om if (this.searchText != null && this.searchText.length() > 0) { this.searchView.setQuery(searchText, false); } return true; }
From source file:com.wearapp.PickFriendsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { //Log.w(TAG, "IN createing Search friends OptionsMenu"); // Inflate the options menu from XML MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); // Assumes current activity is the searchable activity searchView.setSearchableInfo(//from www .j av a 2 s . com searchManager.getSearchableInfo(new ComponentName("com.wearapp", "com.wearapp.HistoryActivity"))); //searchView.setSearchableInfo(searchManager.getSearchableInfo(this.getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default searchView.setQueryHint(getResources().getString(R.string.search_friend_hint)); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { // TODO Auto-generated method stub return false; } @Override public boolean onQueryTextChange(String keyword) { // TODO Auto-generated method stub selectedUsers.addAll(selectedUsers_temp1); //TODO need update FacebookSDK to 2.6 version friendPickerFragment.setSelection(selectedUsers); searchterm = keyword; friendPickerFragment.setFilter(new GraphObjectFilter<GraphUser>() { @Override public boolean includeItem(GraphUser graphObject) { // TODO Auto-generated method stub Pattern p = Pattern.compile(searchterm, Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(graphObject.getName()); if (m.find()) { return true; } return false; } }); friendPickerFragment.loadData(true); return false; } }); return true; }
From source file:ufms.br.com.ufmsapp.fragment.DisciplinasFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); getActivity().getMenuInflater().inflate(R.menu.disciplina_list_menu, menu); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search_disciplina).getActionView(); searchView.setOnQueryTextListener(this); searchView.setQueryHint(getString(R.string.txt_busca)); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); }
From source file:com.tandong.sa.sherlock.widget.SuggestionsAdapter.java
/** * The amount of time we delay in the filter when the user presses the * delete key./*from w w w. j av a 2 s . c o m*/ */ // private static final long DELETE_KEY_POST_DELAY = 500L; public SuggestionsAdapter(Context context, SearchView searchView, SearchableInfo searchable, WeakHashMap<String, Drawable.ConstantState> outsideDrawablesCache) { super(context, context.getResources().getIdentifier("abs__search_dropdown_item_icons_2line", "layout", context.getPackageName()), null, // no // super(context, // R.layout.abs__search_dropdown_item_icons_2line, null, // no // initial // cursor true); // auto-requery mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); mSearchable = searchable; mProviderContext = mContext; mSearchView = searchView; mOutsideDrawablesCache = outsideDrawablesCache; // mStartSpinnerRunnable = new Runnable() { // public void run() { // // mSearchView.setWorking(true); // TODO: // } // }; // // mStopSpinnerRunnable = new Runnable() { // public void run() { // // mSearchView.setWorking(false); // TODO: // } // }; // delay 500ms when deleting // TODO getFilter().setDelayer(new Filter.Delayer() { // // private int mPreviousLength = 0; // // public long getPostingDelay(CharSequence constraint) { // if (constraint == null) return 0; // // long delay = constraint.length() < mPreviousLength ? // DELETE_KEY_POST_DELAY : 0; // mPreviousLength = constraint.length(); // return delay; // } // }); }
From source file:com.zotfeed2.CardContentFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_anteater_tv, menu); // MenuItem item = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.action_search); SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem); if (sv != null) { sv.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*from w ww. jav a 2 s . co m*/ public boolean onQueryTextSubmit(String query) { System.out.print("QUERY:" + query); ArrayList<VideoItem> results = new ArrayList<VideoItem>(); if (!videoBeans.isEmpty() || videoBeans != null) { for (VideoItem videoItem : videoBeans) { //System.out.println("Title: " + article.getTitle()); if (videoItem.getTitle().toLowerCase().contains(query.toLowerCase())) { results.add(videoItem); } } System.out.println("Size: " + results.size()); search = true; recyclerView.setAdapter(new ContentAdapter(results)); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); return true; } else { return false; } } @Override public boolean onQueryTextChange(String newText) { if (newText.isEmpty() || newText.equals(" ")) { if (videoBeans != null) { recyclerView.setAdapter(new ContentAdapter(videoBeans)); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); } } return false; } }); } super.onCreateOptionsMenu(menu, inflater); }
From source file:koma.movieapp.ui.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.search, menu); final MenuItem searchItem = menu.findItem(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 .ja v a 2 s. c om if (view == null) { 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(); Bundle args = new Bundle(); args.putString("title", "Search"); args.putInt("queryType", Config.SEARCH_TOKEN); args.putString("searchString", s); mMoviesFragment.reloadFromArguments(args); return true; } @Override public boolean onQueryTextChange(String s) { // if (null != mMoviesFragment) { // mMoviesFragment.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:ufms.br.com.ufmsapp.fragment.EventosFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); getActivity().getMenuInflater().inflate(R.menu.eventos_list_menu, menu); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setOnQueryTextListener(this); searchView.setQueryHint(getString(R.string.txt_busca)); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); }
From source file:fr.kwiatkowski.apktrack.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); // Change the "Show system apps" text depending on the currently selected option. SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); boolean show_system = pref.getBoolean(SettingsFragment.KEY_PREF_SHOW_SYSTEM, false); if (show_system) { menu.findItem(R.id.show_system).setTitle(R.string.hide_system_apps); }//from w ww . j a va 2 s . c om // Disable it if all system apps are ignored. if (!InstalledApp.check_system_apps_tracked()) { menu.findItem(R.id.show_system).setEnabled(false); } // Change the change sort type text depending on the currently selected option. String sort_type = pref.getString(SettingsFragment.KEY_PREF_SORT_TYPE, SettingsFragment.ALPHA_SORT); if (sort_type.equals(SettingsFragment.ALPHA_SORT)) { menu.findItem(R.id.sort_type).setTitle(R.string.sort_type_updated); } SearchManager seaman = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView sv = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search)); sv.setSearchableInfo(seaman.getSearchableInfo(getComponentName())); sv.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View view) { } @Override public void onViewDetachedFromWindow(View view) { _app_display.restore_apps(); // Unfilter the list when the search bar is closed. } }); return true; }
From source file:com.bukanir.android.activities.MoviesListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); return true;/*from w w w .jav a2 s . c o m*/ }
From source file:ca.zadrox.dota2esportticker.ui.TeamSearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.team_search, menu); MenuItem searchItem = menu.findItem(R.id.action_search); Toolbar.LayoutParams params = new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) searchItem.getActionView(); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setLayoutParams(params); mSearchView.setMaxWidth(getResources().getDisplayMetrics().widthPixels); mSearchView.setIconifiedByDefault(false); mSearchView.setQueryHint("Search"); ImageView magImage = (ImageView) mSearchView.findViewById(R.id.search_mag_icon); magImage.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); final EditText editText = (AutoCompleteTextView) mSearchView.findViewById(R.id.search_src_text); editText.setHintTextColor(getResources().getColor(R.color.theme_primary_light)); if (mQuery != null) { mSearchView.setQuery(mQuery, false); } else {//from w w w. j a va2s . c o m mSearchView.requestFocus(); } mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int i) { return onSuggestionClick(i); } @Override public boolean onSuggestionClick(int i) { Cursor c = (Cursor) mSearchView.getSuggestionsAdapter().getItem(i); mSearchView.setQuery(c.getString(1), true); mSearchView.clearFocus(); return true; } }); return true; }