I need to implement a search interface in my Android app that would filter several RecyclerView
inside a ViewPager
.
I have already implemented both EditText
and SearchView
widgets and try to see differences.
The listeners i am interrested in are :
myEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
And :
mySearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
textView.setText(newText);
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
textView.setText(query);
return true;
}
Am i missing some important features that SearchView
would allow & that EditText
does not ?
With both of these widgets, Am i able to search among RecyclerView
s inside ViewPager
with a single "search-view" ?
I don't want an ACTION_SEARCH
or any added dialog view for the search.
Thanks in advance !
Main Difference between Edittext
and SearchView
is that you can use SearchView as direct implementation for Searching facility in listView/RecyclerView
and on the other side if you use Edittext for this,you have to manually implement code for searching.
Let me provide you direct links for both of this scenarios :
This implementation is for SearchView :
Second one is for EditText :
If you are using searchView,also look at this link :
This will use Edittext For Search data from RecyclerView with custom implementation.
Now, you have to decide which one is more suitable for you and yes,tell me if i can improve my answer or if my answer is unclarified..
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