List of usage examples for android.widget SearchView setOnQueryTextListener
public void setOnQueryTextListener(OnQueryTextListener listener)
From source file:com.github.rutvijkumar.twittfuse.Util.java
public static void setupSearchView(final Activity activity, final SearchView searchView) { int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);/*from w w w. jav a 2 s .com*/ EditText searchPlate = (EditText) searchView.findViewById(searchPlateId); searchPlate.setTextColor(activity.getResources().getColor(android.R.color.white)); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { boolean isValidSubmit = false; if (query != null && !query.isEmpty()) { search(activity, query); isValidSubmit = true; } return isValidSubmit; } @Override public boolean onQueryTextChange(String newText) { // TODO Auto-generated method stub return false; } }); }
From source file:at.wada811.android.library.demos.loader.LoaderListActivity.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void initSearchView(final MenuItem menuItem) { if (AndroidUtils.isMoreThanBuildVersion(Build.VERSION_CODES.ICE_CREAM_SANDWICH)) { final SearchView searchView = (SearchView) menuItem.getActionView(); searchView.setOnQueryTextListener(new OnQueryTextListener() { @Override//from w ww . jav a 2 s . c o m public boolean onQueryTextSubmit(String query) { mLoaderListFragment.init(); mLoaderListFragment.searchImageWithKeyword(query); menuItem.collapseActionView(); getActionBar().setTitle(query); return false; } @Override public boolean onQueryTextChange(String newText) { return false; } }); searchView.setOnQueryTextFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { menuItem.collapseActionView(); } } }); } }
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 . jav a2 s .com*/ }
From source file:de.dknapps.pswgendroid.ServiceListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); MenuItem searchMenuItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) searchMenuItem.getActionView(); searchView.setOnQueryTextListener(serviceListFragment); return true;/*from w w w .j a v a 2s. com*/ }
From source file:com.jaspersoft.android.jaspermobile.activities.repository.fragment.SearchControllerFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); SearchView searchView = (SearchView) searchMenuItem.getActionView(); searchView.setQueryHint(getString(R.string.s_hint)); searchView.setOnQueryTextListener(this); }
From source file:com.javierc.albuquerquenow.SearchMap.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.search_map, menu); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setIcon(R.drawable.home); SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setOnQueryTextListener(n()); return true;//from w w w. j av a 2s .c o m }
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);//from w ww. j a va2 s . c o m }
From source file:me.nereo.gztsg.ui.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); final SearchView mSearchView = (SearchView) menu.findItem(R.id.action_search_book).getActionView(); // setup query listener mSearchView.setOnQueryTextListener(onQueryListener); return true;//from w ww. j av a2s.c o m }
From source file:com.tinbytes.simplesearchapp.SimpleListViewActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_simple_list_view, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search_animal)); if (searchView != null) { searchView.setOnQueryTextListener(this); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); }/*from w w w .ja v a2 s .co m*/ return true; }
From source file:com.pickr.activities.FlickrActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_flickr, menu); SearchView searchView = (SearchView) menu.findItem(R.id.searchField).getActionView(); searchView.setOnQueryTextListener(this); return true;/*w ww . java2s. co m*/ }