I'm new to android programming.
I have a problem with searchview. when I use textlistener, it ALWAYS checks the text while typing and not till user actually taps search in the search bar!
SearchView searchView = (SearchView) findViewById(R.id.Search_View);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
///Toast.makeText(getApplicationContext(),query,Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Toast.makeText(getApplicationContext(),newText,Toast.LENGTH_SHORT).show();
return false;
}
});
so when I type in searchbox, the message toasted letter by letter while I'm typing and not let me click on search on keyboard.
I searched a lot and couldn't find a solution. Thanks for your solutions... :)
SearchView is supposed to give users suggestion while typing. If you need to serch entire sentence or word consider using a EditText with a button instead of SearchView. Set listener to the button and start action (Toast the message) after user tap it.