CursorAdapter
继承于BaseAdapter是个虚类,它为cursor和ListView提供了连接的桥梁。
public abstract class CursorAdapter extends BaseAdapter
直接子类只有ResourceCursorAdapter
Class Overview
Adapter that exposes data from a Cursor to a ListView widget.
The Cursor must include a column named "_id" or this class will not work.
注意cursor的必须要有个命名为"_id"的列。比如Contacts._ID就为"_id"
必须实现以下函数 :
abstract View newView(Context context, Cursor cursor, ViewGroup parent)
Makes a new view to hold the data pointed to by cursor(生成一个新的视图来保存光标指向的数据).
abstract void bindView(View view, Context context, Cursor cursor)
Bind an existing view to the data pointed to by cursor(绑定光标指向的数据到现有的视图中)
注意:
newView该函数第一次回调用后,如果数据增加后也会再调用,但是重绘是不会调用的。
数据增加后,回调用该函数来生成与新增数据相对应的view。
bindView函数第一次回调用后,如果数据更新也会再调用,但重绘会再次调用的。
【总的来说应该是在调用bindView如果发现view为空会先调用newView来生成view】
public abstract class CursorAdapter extends BaseAdapter
直接子类只有ResourceCursorAdapter
Class Overview
Adapter that exposes data from a Cursor to a ListView widget.
The Cursor must include a column named "_id" or this class will not work.
注意cursor的必须要有个命名为"_id"的列。比如Contacts._ID就为"_id"
abstract View newView(Context context, Cursor cursor, ViewGroup parent)
Makes a new view to hold the data pointed to by cursor(生成一个新的视图来保存光标指向的数据).
abstract void bindView(View view, Context context, Cursor cursor)
Bind an existing view to the data pointed to by cursor(绑定光标指向的数据到现有的视图中)
注意:
newView该函数第一次回调用后,如果数据增加后也会再调用,但是重绘是不会调用的。
数据增加后,回调用该函数来生成与新增数据相对应的view。
bindView函数第一次回调用后,如果数据更新也会再调用,但重绘会再次调用的。
【总的来说应该是在调用bindView如果发现view为空会先调用newView来生成view】