I sub classed SimpleAdapter
to add some extra functionality to it, like changing background color, custom views and filtering. The background thing is working out g
No need to add filter
and bindView
methods, only make sure for getView
:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
if(position%2!=0) {
v.setBackgroundColor(Color.DKGRAY);
}
else {
v.setBackgroundColor(Color.BLACK);
}
return v;
}
Try this code:
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
data.clear();
data.addAll((List<Map<String, String>>) results.values);
if (results.count > 0) {
notifyDataSetChanged();
} else {
notifyDataSetInvalidated();
}
}