Reputation: 163
It is little abstract question but i cannot find any solution for that. Is there any way for using searchview without intent ? I am trying to search something without creating activity again.
Upvotes: 4
Views: 295
Reputation: 715
Actually you don't need use any of these if you want. You may simply override the callbacks of the SearchView.OnQueryTextListener.
See the following example:
public class MySearchActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SearchView searchView = (SearchView) findViewById(R.id.searchView);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
//Every hit on "Enter"
doSearch(s);
return true;
}
@Override
public boolean onQueryTextChange(String s) {
//Any change in the query string
doSearch(s);
return true;
}
});
}
/*
* Implement your search into a SQLite database, webservice or anything else...
* */
private void doSearch(String query) {
searchAndNotifyAdapterWithResult(query);
}
}
Upvotes: 2
Reputation: 19351
Actually there are some libraries which you can use for this
Of course, these are only examples of many others which you would find on GitHub page. So be patient and find the one which would be the most comfortable to you and the best fit for your app.
Upvotes: 2