IndexOutOfBoundException on filtering SimpleAdapter

前端 未结 2 356
一整个雨季
一整个雨季 2021-01-21 10:05

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

2条回答
  •  不知归路
    2021-01-21 10:54

    Try this code:

    @SuppressWarnings("unchecked")
    @Override
    protected void publishResults(CharSequence constraint, FilterResults results) {
        data.clear();
        data.addAll((List>) results.values);
        if (results.count > 0) {
           notifyDataSetChanged();
        } else {
           notifyDataSetInvalidated();
        }
    }
    

提交回复
热议问题