Filter a list when text is change in a List

Total Post:27

Points:189
 898  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. 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 Apr-09-2018 02:17:53 AM

Answer