Home > DeveloperSection > Forums > Filter a list when text is change in a List
Lillian Martin

Total Post:27

Points:189
Posted on    March-20-2015 3:00 AM

 Android Android  ListView 
Ratings:


 1 Reply(s)
 439  View(s)
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



Manoj Pandey

Total Post:26

Points:188
Posted on    March-20-2015 3:30 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick