Reputation: 1435
Hello I am trying to know when the user hits the search/submit button on a searchView but they have not entered any text. I am aware I can use setOnQueryTextListener but this will only get called if the user enters some text. If you have any ideas please let me know. Thank you!!
Upvotes: 0
Views: 31
Reputation: 1264
verify the length of the text entered like this:
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String key) {
if(key.length()>2){//if the text to search more then 2 caracter
//user hit the search button, do your search
}
return false;}
@Override
public boolean onQueryTextChange(String s) {
// user is typing ...
return false;
}
});
Upvotes: 1