JoanZapata / base-adapter-helper

Abstraction for the usual BaseAdapter "ViewHolder" pattern
http://joanzapata.com/base-adapter-helper/
Other
1.76k stars 530 forks source link

notifyDataSetChanged can not work #44

Closed chefish closed 9 years ago

chefish commented 9 years ago
public BaseQuickAdapter(Context context, int layoutResId, List<T> data) {
    this.data = data == null ? new ArrayList<T>() : new ArrayList<T>(data);
    this.context = context;
    this.layoutResId = layoutResId;
}

The data is always new. So we cannot use notifyDataSetChanged. I think it shoud be this.data = data == null ? new ArrayList() : data;

JoanZapata commented 9 years ago

The BaseQuickAdapter creates its own list because it's safer: if you remove an element of your list and don't notify the adapter, it would make your app crash because the adapter will try to build items which don't exist anymore.

If you updated your list, please use replaceAll instead. It will update the internal adapter list and call notifyDatasetChanged() for you.