In Android SearchView widget that provides a UI. It will search query and submit a request to a search provider.
There are different type of search query Provided by Collections like BinarySearch...
What kind of Search query performed by Android Widget SearchView.?
(BinarySearch Or LinerSearch Or anything else...)
If you ask about android.widget.SearchView
, you can implement interface android.widget.SearchView.OnQueryTextListener
and do anything you want inside it.
For example, let's create OnQueryTextListener
as Activity part:
public class MyActivity implements OnQueryTextListener{
@Override
protected void onCreate(Bundle savedInstanceState){
...
SearchView s=new SearchView(this);
s.setFitsSystemWindows(true);
s.setMaxWidth(Integer.MAX_VALUE);
s.setIconifiedByDefault(false);
s.setOnQueryTextListener(this); // <--- this sets listener
...
}
And now two methods what you have to implement:
@Override
public boolean onQueryTextChange(String newText){
return false; // <--- you can leave it empty!
}
@Override
public boolean onQueryTextSubmit(String query){
if(!query.isEmpty()){
do_something_on_user_post();
}
return false;
}
It is up to the app developer to search the data and to provide the results to the search widget. The search widget provides a framework for the app to perform its searches but does not search the data directly. From Creating a Search Interface:
Searching your data
The process of storing and searching your data is unique to your application. You can store and search your data in many ways, but this guide does not show you how to store your data and search it. Storing and searching your data is something you should carefully consider in terms of your needs and your data format.
So you can search your data in the way that makes the most sense for how the data is stored and organized.
An Android "Widget" is to perform the search but does not search the data directly you implement your own search algorithm
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