I am trying to search data by ListView data coming from a websevice.. 

Description: if I enter *[abc]* in search editview[searchText] and if I 
click serachbutton(buttonSearch), it must show all related data in 
listview(listView) 

Ex: abc, abacd, abcderg etc. in this way...

This topic is new for me. 

Here is my code. Please help me do it. 
I have tried, but I was not able to figure out how to do thi

   
ArrayList<Patient> patientListArray;


 listView = (ListView) findViewById(R.id.workListview);
    objectAdapter = new WorkListAdapter(this, patientListArray);
    listView.setAdapter(objectAdapter);     
    listView.setTextFilterEnabled(true);

    searchText = (EditText) findViewById(R.id.searchView);
    searchText.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) {
             dataAdapter.getFilter().filter(s.toString());


        }
    }); 

WorkListAdapter.java

public Filter getFilter() {

    Filter myFilter = new Filter() {



        @Override
        protected void publishResults(CharSequence constraint, FilterResults 
results) {

            if (!patientListArray.isEmpty()){
                clear();
            }

            for (int i = 0; i < patientListArray.size(); i++) {
                
if(patientListArray.get(i).getName().toLowerCase().startsWith(constraint.toString().toLowerCase())){
                    add(patientListArray.get(i));
                }
            }

            notifyDataSetChanged();
        }

        private void add(Patient patient) {


        }

        private void clear() {


        }

        @Override
        protected FilterResults performFiltering(CharSequence constraint) {

            return null;
        }
    };  

    return myFilter;
}


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to