FILTER A LIST WHEN TEXT IS CHANGE IN A LIST

Lillian Martin

Total Post:27

Points:189
Posted by  Lillian Martin
 676  View(s)
Ratings:
Rate this:

EditText inputSearch = (EditText) getView().findViewById(R.id.inputGroupSearch);

    inputSearch.addTextChangedListener(new TextWatcher() {

 

        @Override

        public void onTextChanged(CharSequence cs, int arg1, int arg2,

                int arg3) {

            // When user changed the Text

            Myadapter.getFilter().filter(cs);

        }})

but this code is not running

  1. Manoj Pandey

    Post:26

    Points:188
    Re: Filter a list when text is change in a List

    Add following code for filter list on edittext type


    editText = (EditText) view.findViewById(R.id.filerText);

         editText.addTextChangedListener(new TextWatcher() {  

             @Override

             public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {

                YourCustomAdapter Myadapter= (YourCustomAdapter) getListAdapter();

                      Myadapter.getFilter().filter(cs);

             } 

             @Override

             public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } 

             @Override

             public void afterTextChanged(Editable arg0) {}

         });


     

      Modified On Mar-20-2015 05:01:28 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!