how to get the events of searchview in android
The above answer is good but not complete actually you need to set an action listener for your Search view . you can do this in two ways create a class that implements the necessary classes to be an OnQueryTextListener and make a new object of that and use it as your search view query text listener or use the following compact form:
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
callSearch(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
// if (searchView.isExpanded() && TextUtils.isEmpty(newText)) {
callSearch(newText);
// }
return true;
}
public void callSearch(String query) {
//Do searching
}
});
Try to use setOnQueryTextListener of SearchView
new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
// your text view here
textView.setText(newText);
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
textView.setText(query);
return true;
}
}