List of usage examples for android.widget SearchView setSearchableInfo
public void setSearchableInfo(SearchableInfo searchable)
From source file:no.group09.ucsoftwarestore.MainActivity.java
/** * Creates options menu//from w ww .j a v a2 s.c o m */ @SuppressLint("NewApi") @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_menu, menu); //When the menu is created, check the preferences and set the correct text if (sharedPref.getBoolean("hide_incompatible", false)) { menu.getItem(1).setTitle("Hide incompatible"); menu.getItem(1).setChecked(true); } else { menu.getItem(1).setTitle("Hide incompatible"); menu.getItem(1).setChecked(false); } //Search bar for versions over API level 11 int SDK_INT = android.os.Build.VERSION.SDK_INT; if (SDK_INT >= 11) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(true); } return true; }
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/*from www . j av a2s .c om*/ 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:org.transdroid.core.gui.search.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Manually insert the actions into the main torrent and secondary actions toolbars searchToolbar.inflateMenu(R.menu.activity_search); // Add an expandable SearchView to the action bar MenuItem item = menu.findItem(R.id.action_search); final SearchView searchView = new SearchView(getSupportActionBar().getThemedContext()); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryRefinementEnabled(true); searchView.setIconified(false);//from w w w . ja v a 2s.c o m searchView.setIconifiedByDefault(false); MenuItemCompat.setActionView(item, searchView); searchMenu = item; return true; }
From source file:com.conferenceengineer.android.iosched.ui.SearchActivity.java
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) 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 && UIUtils.hasHoneycomb()) { SearchView searchView = (SearchView) searchItem.getActionView(); if (searchView != null) { SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryRefinementEnabled(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*w ww . ja v a2 s.co 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; } }); } } return true; }
From source file:com.jbirdvegas.mgerrit.ProjectsList.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the options menu from XML MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.projects_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(true); searchView.setOnQueryTextListener(this); return true;/*ww w .ja v a2 s . c o m*/ }
From source file:com.owncloud.android.ui.fragment.SearchShareesFragment.java
/** * {@inheritDoc}// w ww . ja va 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: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 w w . jav a 2s. 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: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 www.j av a 2 s . c o m*/ }
From source file:com.hybris.mobile.activity.StoreLocatorActivity.java
/** * Menu methods// www . ja v a 2 s .c o m */ @Override public boolean onCreateOptionsMenu(final Menu menu) { MenuInflater inflater = this.getMenuInflater(); inflater.inflate(R.menu.store_finder, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchViewMenuItem = menu.findItem(R.id.store_search); this.mSearchView = searchViewMenuItem; SearchView searchView = ((SearchView) searchViewMenuItem.getActionView()); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); searchView.setQueryHint(getResources().getString(R.string.store_search_hint)); searchView.setOnQueryTextListener(this); return true; }
From source file:jm.org.data.area.IndicatorActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.main, menu); //Log.d(TAG, "OnCreateOptionsMenu"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // only for android newer than gingerbread // TODO Implement a Search Dialog fall back for compatibility with // Android 2.3 and lower // Currently crashes on Gingerbread or lower // 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(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); // Do not iconify the // widget; expand it by // default }/* w w w . j av a2 s. c o m*/ return super.onCreateOptionsMenu(menu); }