I'm using a searchView
and try to pass some data when someone invokes a search. So i overrode the onSearchReqested
method. The problem is, this method isn't called when someone types in the SearchView
and presses the magnifying glass on the keyboard. Instead the result activity is started.
How can i call the onSearchRequested
method prior starting the result activity when someone presses the magnifying glass.
i tried this two but it didnt work.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.FLAG_EDITOR_ACTION) {
onSearchRequested();
return false;
}
return false;
}
adding a listener to the searchview didn't work either
searchView.setOnSearchClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onSearchRequested();
}
});
Thanks in advance for the help.
setOnQueryTextListerner finally worked
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
onSearchRequested();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
return false;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With