List of usage examples for android.widget SearchView setOnCloseListener
public void setOnCloseListener(OnCloseListener listener)
From source file:com.openerp.addons.note.AddFollowerFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_fragment_note, menu); SearchView searchView = (SearchView) menu.findItem(R.id.menu_note_search).getActionView(); searchView.setOnQueryTextListener(getQueryListener(listAdapters)); searchView.setOnCloseListener(new OnCloseListener() { @Override/* w w w. jav a 2 s. c o m*/ public boolean onClose() { getPartnersFromLocal(); return false; } }); // disabling the COMPOSE NOTE,WRITE,CANCEL options MenuItem item_compose = menu.findItem(R.id.menu_note_compose); item_compose.setVisible(false); MenuItem item_write = menu.findItem(R.id.menu_note_write); item_write.setVisible(false); MenuItem item_cancel = menu.findItem(R.id.menu_note_cancel); item_cancel.setVisible(false); }
From source file:org.namelessrom.devicecontrol.modules.appmanager.BaseAppListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_app_list, menu); // setup search final MenuItem searchItem = menu.findItem(R.id.action_search); final SearchView searchView = (searchItem != null ? (SearchView) searchItem.getActionView() : null); if (searchView != null) { searchView.setOnQueryTextListener(this); searchView.setOnCloseListener(this); }/* ww w.j av a2 s . com*/ super.onCreateOptionsMenu(menu, inflater); }
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/* w w w . j a v a 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.jitsi.android.gui.contactlist.ContactListFragment.java
/** * {@inheritDoc}// w ww. j a va2s . co m */ @Override public void onPause() { super.onPause(); // Unbind search listener if (searchItem != null) { SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setOnQueryTextListener(null); searchView.setOnCloseListener(null); } // Save scroll position scrollPosition = contactListView.getFirstVisiblePosition(); View itemView = contactListView.getChildAt(0); scrollTopPosition = itemView == null ? 0 : itemView.getTop(); // Dispose of group expand memory if (listExpandHandler != null) { listExpandHandler.unbind(); listExpandHandler = null; } contactListView.setAdapter((ExpandableListAdapter) null); if (contactListAdapter != null) { contactListAdapter.dispose(); contactListAdapter = null; } disposeSourcesAdapter(); }
From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java
private void bindSearchListener() { if (searchItem != null) { SearchView searchView = (SearchView) searchItem.getActionView(); SearchViewListener listener = new SearchViewListener(); searchView.setOnQueryTextListener(listener); searchView.setOnCloseListener(listener); }/*from w ww. j a v a2 s .c o m*/ }
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.jav a2 s .c o m*/ 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:biz.bokhorst.xprivacy.ActivityMain.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); if (inflater != null && PrivacyService.checkClient()) { // Inflate menu inflater.inflate(R.menu.main, menu); // Searchable SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search)); if (searchView != null) { searchView.setIconifiedByDefault(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*from w w w.j a v a2 s.c o m*/ public boolean onQueryTextChange(String newText) { searchQuery = newText; applyFilter(); return true; } @Override public boolean onQueryTextSubmit(String query) { searchQuery = query; applyFilter(); return true; } }); searchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { searchQuery = ""; applyFilter(); return true; } }); } return true; } else return false; }