List of usage examples for android.widget SearchView SearchView
public SearchView(Context context)
From source file:com.example.ward.view.CursorFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Place an action bar item for searching. MenuItem item = menu.add("Search"); item.setIcon(android.R.drawable.ic_menu_search); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); SearchView sv = new SearchView(getActivity()); sv.setOnQueryTextListener(this); item.setActionView(sv);/*from w w w. j a va 2 s . co m*/ }
From source file:se.eliga.aves.birdlist.BirdListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.main_menu, menu); MenuItem item = menu.findItem(R.id.species_search); SearchView searchView = new SearchView(((MainActivity) getActivity()).getActionBar().getThemedContext()); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW | MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.setActionView(item, searchView); final BirdListAdapter birdListAdapter = (BirdListAdapter) getListAdapter(); searchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override/*from w ww . j a va 2 s . c o m*/ public boolean onClose() { birdListAdapter.setFilterString(null); birdListAdapter.refresh(); birdListAdapter.notifyDataSetChanged(); return false; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { birdListAdapter.setFilterString(query); birdListAdapter.refresh(); birdListAdapter.notifyDataSetChanged(); return true; } @Override public boolean onQueryTextChange(String newText) { birdListAdapter.setFilterString(newText); birdListAdapter.refresh(); birdListAdapter.notifyDataSetChanged(); return true; } }); }
From source file:org.strongswan.android.ui.TrustedCertificateListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(R.string.search); item.setIcon(android.R.drawable.ic_menu_search); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); SearchView sv = new SearchView(getActivity()); sv.setOnQueryTextListener(this); item.setActionView(sv);//w w w . j a v a 2 s.c o m }
From source file:net.ustyugov.jtalk.activity.XMLConsole.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.xml, menu);// ww w . j av a 2 s . co m MenuItem.OnActionExpandListener listener = new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { searchString = ""; updateList(); return true; } @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } }; SearchView searchView = new SearchView(this); searchView.setQueryHint(getString(android.R.string.search_go)); searchView.setSubmitButtonEnabled(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { return false; } @Override public boolean onQueryTextSubmit(String query) { searchString = query; updateList(); return true; } }); MenuItem item = menu.findItem(R.id.search); item.setActionView(searchView); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); item.setOnActionExpandListener(listener); return super.onCreateOptionsMenu(menu); }
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 .j a v a2 s . c om searchView.setIconifiedByDefault(false); MenuItemCompat.setActionView(item, searchView); searchMenu = item; return true; }
From source file:ca.appvelopers.mcgillmobile.ui.MapActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.search, menu); // Get the SearchView MenuItem item = menu.findItem(R.id.action_search); Assert.assertNotNull(getSupportActionBar()); final SearchView searchView = new SearchView(this); final int textViewID = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);// w w w.ja v a2s . c om final AutoCompleteTextView searchTextView = (AutoCompleteTextView) searchView.findViewById(textViewID); try { // Set the cursor to the same color as the text Field cursorDrawable = TextView.class.getDeclaredField("mCursorDrawableRes"); cursorDrawable.setAccessible(true); cursorDrawable.set(searchTextView, 0); } catch (Exception e) { Timber.e(e, "Cannot change color of cursor"); } // Set up the query listener MenuItemCompat.setActionView(item, searchView); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { searchString = query; filterBySearchString(); return false; } @Override public boolean onQueryTextChange(String newText) { searchString = newText; filterBySearchString(); return false; } }); //Reset the search view searchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { searchString = ""; filterBySearchString(); return false; } }); return true; }
From source file:br.com.GUI.aulas.Agenda.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.agenda_actions, menu); final SearchView searchView = new SearchView(getActivity().getActionBar().getThemedContext()); searchView.setQueryHint("Search"); menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search) .setActionView(searchView)// w w w.j a v a2 s . c o m .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { if (newText.length() > 0) { // Search atualizarAgenda(newText.toString()); } else { // Do something when there's no input atualizarAgenda(newText.toString()); } return false; } @Override public boolean onQueryTextSubmit(String arg0) { // TODO Auto-generated method stub atualizarAgenda(arg0.toString()); return false; } }); }
From source file:com.melchor629.musicote.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { //Create the search view SearchView searchView = new SearchView(getActionBar().getThemedContext()); searchView.setQueryHint(getResources().getString(R.string.menu_search)); searchView.setOnQueryTextListener(this); menu.add("Search") .setIcon(new IconDrawable(this, Iconify.IconValue.fa_search).color(Color.WHITE).actionBarSize())//android.R.drawable.ic_menu_search) .setActionView(searchView)//from ww w.ja v a 2 s .c om .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); getMenuInflater().inflate(R.menu.main, menu); menu.findItem(R.id.ajustesm) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_cogs).color(Color.WHITE).actionBarSize()); menu.findItem(R.id.parar) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_music).color(Color.WHITE).actionBarSize()); return true; }
From source file:br.com.GUI.perfil.MeusAlunos.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.adicionar_aluno_actions, menu); final SearchView searchView = new SearchView(getActivity().getActionBar().getThemedContext()); searchView.setQueryHint("Search"); menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search) .setActionView(searchView)// www. ja v a 2s. c o m .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { if (newText.length() > 0) { // Search atualizarMeusAlunos(newText.toString()); } else { // Do something when there's no input atualizarMeusAlunos(newText.toString()); } return false; } @Override public boolean onQueryTextSubmit(String arg0) { // TODO Auto-generated method stub atualizarMeusAlunos(arg0.toString()); return false; } }); }
From source file:br.com.GUI.perfil.BuscarUsuario.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.buscar_usuario, menu); final SearchView searchView = new SearchView(this.getActionBar().getThemedContext()); searchView.setQueryHint("Search"); menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search) .setActionView(searchView)//w w w . j a v a2 s .co m .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { /* if (newText.length() > 0) { if(pref.getString("tipo", null).equals("personal")){ pesquisarAluno(newText.toString()); }else if(pref.getString("tipo", null).equals("aluno")){ pesquisarPersonal(newText.toString()); } } else { if(pref.getString("tipo", null).equals("personal")){ pesquisarAluno(""); }else if(pref.getString("tipo", null).equals("aluno")){ pesquisarPersonal(""); } }*/ return false; } @Override public boolean onQueryTextSubmit(String arg0) { if (pref.getString("tipo", null).equals("personal")) { pesquisarAluno(arg0); } else if (pref.getString("tipo", null).equals("aluno")) { pesquisarPersonal(arg0); } return false; } }); return true; }