when i call the notifyDataSetChanged(), but the getView seems not work
as expect.
for example, there are 10 rows, after my filter by Filterable
interface, there's 1 row left, and i call notifyDataSetChanged()
, so the getView would excute 10 times, but not 1 time

how to rebind the list data after filter?

this is my code:
static class ContactListAdapter extends BaseAdapter implements
Filterable {
                private final NameFilter filter;
                @Override
                public Filter getFilter() {
                        // TODO Auto-generated method stub
                        return filter;
                }

                private class NameFilter extends Filter{

                        @Override
                        protected FilterResults performFiltering(CharSequence 
constraint) {
                                final FilterResults oReturn = new 
FilterResults();
                                final ArrayList<Contact> results = new 
ArrayList<Contact>();
                                //if (arrayContacts == null)
                                arrayContacts = mListContacts.getContacts();

                                if (constraint != null)
                                        if (arrayContacts != null && 
arrayContacts.size() > 0) {
                                                for (final Contact c : 
arrayContacts) {
                                                        if 
(c.getDisplayName().startsWith(
                                                                        
constraint.toString()))
                                                                results.add(c);
                                                }
                                        }
                                oReturn.values = results;

                                return oReturn;
                        }

                        @Override
                        protected void publishResults(CharSequence constraint,
                                        FilterResults results) {
                                arrayContacts = (ArrayList<Contact>) 
results.values;
                                Log.i("info", "filtered contacts count:" +
Integer.toString(arrayContacts.size()));
                                notifyDataSetChanged();
                        }
                }
}

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

Reply via email to