List of usage examples for android.app SearchManager getSearchableInfo
public SearchableInfo getSearchableInfo(ComponentName componentName)
From source file:com.fjoglar.etsitnoticias.view.activities.NewsListActivity.java
private void setUpSearchView(MenuItem searchMenuItem, final MenuItem filterMenuItem) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) searchMenuItem.getActionView(); searchView.setMaxWidth(Integer.MAX_VALUE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); TextView searchText = (TextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text); searchText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL)); // Hide filter option when SearchView is expanded, restore it when collapsed. MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override/*w ww . j a v a2 s . c om*/ public boolean onMenuItemActionExpand(MenuItem item) { filterMenuItem.setVisible(false); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { filterMenuItem.setVisible(true); return true; } }); }
From source file:com.andrew.apollo.ui.activities.SearchActivity.java
/** * {@inheritDoc}//w w w. j a v a2 s . c o m */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getSupportMenuInflater().inflate(R.menu.search, menu); // Theme the search icon mResources.setSearchIcon(menu); // Filter the list the user is looking it via SearchView mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); mSearchView.setOnQueryTextListener(this); // Add voice search final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); mSearchView.setSearchableInfo(searchableInfo); return super.onCreateOptionsMenu(menu); }
From source file:com.hannesdorfmann.search.SearchActivity.java
private void setupSearchView() { SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // hint, inputType & ime options seem to be ignored from XML! Set in code searchView.setQueryHint(getString(R.string.search_hint)); searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS); searchView.setImeOptions(searchView.getImeOptions() | EditorInfo.IME_ACTION_SEARCH | EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN); }/* w w w . j a v a2s . co m*/
From source file:com.ksharkapps.musicnow.ui.activities.BaseActivity.java
/** * {@inheritDoc}//from www. ja v a 2 s .c o m */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getMenuInflater().inflate(R.menu.search, menu); // Settings getMenuInflater().inflate(R.menu.activity_base, menu); MenuItem searchItem = menu.findItem(R.id.menu_search); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); // Add voice search final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); searchView.setSearchableInfo(searchableInfo); // Perform the search if (searchView != null) searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(final String query) { // Open the search activity NavUtils.openSearch(BaseActivity.this, query); return true; } @Override public boolean onQueryTextChange(final String newText) { // Nothing to do return false; } }); return super.onCreateOptionsMenu(menu); }
From source file:org.openmrs.client.activities.FindPatientsActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from w ww . j a v a2 s. co m public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.find_patients_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView findPatientView; mFindPatientMenuItem = menu.findItem(R.id.actionSearch); if (OpenMRS.getInstance().isRunningHoneycombVersionOrHigher()) { findPatientView = (SearchView) mFindPatientMenuItem.getActionView(); } else { findPatientView = (SearchView) MenuItemCompat.getActionView(mFindPatientMenuItem); } SearchableInfo info = searchManager.getSearchableInfo(getComponentName()); findPatientView.setSearchableInfo(info); return true; }
From source file:com.hybris.mobile.activity.StoreLocatorActivity.java
/** * Menu methods//from www.j av 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:com.thelastcrusade.soundstream.CoreActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the options menu from XML getMenuInflater().inflate(R.menu.search_menu, menu); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) searchItem.getActionView(); if (searchView != null) { searchView.setSearchableInfo(/* www. j a va 2 s.c o m*/ searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class))); searchView.setIconified(true); searchView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { v.setFocusable(true); v.requestFocusFromTouch(); } }); if (isConnectActive()) { searchItem.setVisible(false); } } return true; }
From source file:com.necisstudio.highlightgoal.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.refresh) { drawermenu(iddrawer);/* w w w.j a v a 2s. c o m*/ return true; } else if (id == R.id.search) { item.expandActionView(); MenuItemCompat.setOnActionExpandListener(item, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { // getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); ApplicationConfig.status = R.id.latest; iddrawer = R.id.latest; imgLogo.setImageResource(0); txtTitle.setText("Latest"); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments(HighlightLatestFragment.newInstance(""), KlasementLigaFragment.newInstance("inggris"), ScheduleLigaLatestFragment.newInstance("")); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Schedule"); return true; } }); searchview = (SearchView) MenuItemCompat.getActionView(item); SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchview.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchview.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); iddrawer = 20; fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments( HighlightLatestFragment.newInstance(searchview.getQuery().toString()), KlasementLigaFragment.newInstance("inggris"), ScheduleLigaLatestFragment.newInstance(searchview.getQuery().toString())); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Schedule"); return false; } @Override public boolean onQueryTextChange(String newText) { return false; } }); } return super.onOptionsItemSelected(item); }
From source file:org.kontalk.ui.ConversationsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.conversation_list_menu, menu); // search/*from ww w. j av a 2 s.c om*/ mSearchMenu = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(mSearchMenu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(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(); return true; }
From source file:com.jtechme.apphub.FDroid.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); if (fdroidApp.bluetoothAdapter == null) { // ignore on devices without Bluetooth MenuItem btItem = menu.findItem(R.id.action_bluetooth_apk); btItem.setVisible(false);/*from w w w .j av a 2 s.co m*/ } SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchMenuItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // LayoutParams.MATCH_PARENT does not work, use a big value instead searchView.setMaxWidth(1000000); searchView.setOnQueryTextListener(this); // If we were asked to execute a search before getting around to building the options // menu, then we should deal with that now that the options menu is all sorted out. if (pendingSearchQuery != null) { performSearch(pendingSearchQuery); pendingSearchQuery = null; } return super.onCreateOptionsMenu(menu); }