Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText AND SearchView : What are the main differences (except the design)?

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;
    }
  1. Am i missing some important features that SearchView would allow & that EditText does not ?

  2. 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 !

like image 429
Tom3652 Avatar asked Jan 20 '20 15:01

Tom3652


1 Answers

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 :

  1. https://www.androidhive.info/2017/11/android-recyclerview-with-search-filter-functionality/

Second one is for EditText :

  1. https://stackoverflow.com/a/40757114/10752962

If you are using searchView,also look at this link :

  1. https://stackoverflow.com/a/34880830/10752962

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..

like image 78
Vivek Thummar Avatar answered Oct 20 '22 06:10

Vivek Thummar