List of usage examples for android.app SearchManager getSearchableInfo
public SearchableInfo getSearchableInfo(ComponentName componentName)
From source file:com.nachtimwald.android.serviceexplorer.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_options, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(true); searchView.setOnQueryTextListener(this); return super.onCreateOptionsMenu(menu); }
From source file:net.abcdroid.devfest12.ui.SearchActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupSearchMenuItem(Menu menu) { final MenuItem searchItem = menu.findItem(R.id.menu_search); if (searchItem != null && UIUtils.hasHoneycomb()) { SearchView searchView = (SearchView) searchItem.getActionView(); if (searchView != null) { SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//from w ww .ja va2 s.c o m public boolean onQueryTextSubmit(String s) { ReflectionUtils.tryInvoke(searchItem, "collapseActionView"); return false; } @Override public boolean onQueryTextChange(String s) { return false; } }); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int i) { return false; } @Override public boolean onSuggestionClick(int i) { ReflectionUtils.tryInvoke(searchItem, "collapseActionView"); return false; } }); } } }
From source file:net.vivekiyer.GAL.CorporateContactRecord.java
/** * @param menu//from w w w .j ava 2s. co m * @param v * @param menuInfo * * Create a context menu for the list view Depending upon the * item selected, shows the user different options */ /* * (non-Javadoc) * * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu) * * Displays the menu when the user clicks the Options button In our case the * menu contains only one button - save */ @TargetApi(11) @Override public boolean onCreateOptionsMenu(Menu menu) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.contacts_menu, menu); // Get the SearchView and set the searchable configuration for Honeycomb // and above if (!Utility.isPreHoneycomb()) { final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final ComponentName component = getComponentName(); final SearchableInfo searchableInfo = searchManager.getSearchableInfo(component); searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setSearchableInfo(searchableInfo); } return true; }
From source file:de.aw.monma.hbci.FragmentHBCIBanken.java
/** * In der ActionBar die SearchView initialisieren *///from w w w. ja v a 2 s . c o m @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_hbcibank, menu); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_List_search)); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); searchView.setOnQueryTextListener(this); super.onCreateOptionsMenu(menu, inflater); }
From source file:igor70334.mymovies.ui.activity.BaseActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView;//from w w w .jav a2 s .c o m MenuItem item = menu.findItem(R.id.search); searchView = (SearchView) item.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryHint(getResources().getString(R.string.search_hint)); return true; }
From source file:it.gulch.linuxday.android.activities.SearchResultActivity.java
@SuppressLint("NewApi") @Override/*from w w w .j av a 2 s.c o m*/ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.search, menu); MenuItem searchMenuItem = menu.findItem(R.id.search); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Always show the search view setSearchViewQuery(currentQuery); } else { // Legacy search mode for Eclair MenuItemCompat.setActionView(searchMenuItem, null); getSupportActionBar().setSubtitle(currentQuery); } return true; }
From source file:com.bdenney.locl.activity.NearbyActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the options menu from XML MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.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(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default if (!TextUtils.isEmpty(getSearchTerm())) { final MenuItem item = menu.findItem(R.id.menu_search); if (item != null) { item.setVisible(false);/*from w w w. j ava 2s . c o m*/ } } return true; }
From source file:org.onebusaway.android.util.UIUtils.java
/** * Sets up the search view in the action bar *///from ww w .ja v a2s .c o m public static void setupSearch(Activity activity, Menu menu) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); final MenuItem searchMenu = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenu); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); // Close the keyboard and SearchView at same time when the back button is pressed searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean queryTextFocused) { if (!queryTextFocused) { MenuItemCompat.collapseActionView(searchMenu); } } }); } }
From source file:com.cerema.cloud2.ui.fragment.SearchShareesFragment.java
/** * {@inheritDoc}//from ww w.j a v a 2 s. co m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.search_users_groups_layout, container, false); // Get the SearchView and set the searchable configuration SearchView searchView = (SearchView) view.findViewById(R.id.searchView); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()) // assumes parent activity is the searchable activity ); searchView.setIconifiedByDefault(false); // do not iconify the widget; expand it by default searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); // avoid fullscreen with softkeyboard searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { Log_OC.v(TAG, "onQueryTextSubmit intercepted, query: " + query); return true; // return true to prevent the query is processed to be queried; // a user / group will be picked only if selected in the list of suggestions } @Override public boolean onQueryTextChange(String newText) { return false; // let it for the parent listener in the hierarchy / default behaviour } }); return view; }
From source file:org.mythtv.android.player.app.videos.VideosActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the options menu from XML MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search_action).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); return super.onCreateOptionsMenu(menu); }