我尝试过执行listview过滤器。但是过滤有时候不能正常工作。有时它的工作正常。我不知道这个错误是怎么发生的。我试过这个:
public Filter getFilter() {
if (valueFilter == null) {
valueFilter = new ValueFilter();
}
return valueFilter;
}
private class ValueFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
List<HomepageGS> filterList = new ArrayList<HomepageGS>();
if (constraint != null && constraint.length() > 0) {
for (int i = 0; i < mStringFilterList.size(); i++) {
if ((mStringFilterList.get(i).getsearchjob_title().toUpperCase())
.contains(constraint.toString().toUpperCase())) {
HomepageGS contacts = new HomepageGS();
HomepageGS m = mStringFilterList.get(i);
filterList.add(m);
}
}
results.count = filterList.size();
results.values = filterList;
} else {
results.count = filterList.size();
results.values = filterList;
}
return results;
}
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
mainpagelist1 = (List<HomepageGS>) results.values;
notifyDataSetChanged();
}
}
] 1
] 2