Android 如何在BaseAdapter中更新自定义变量?
在Android中,我编写了一个类Android 如何在BaseAdapter中更新自定义变量?,android,baseadapter,notifydatasetchanged,Android,Baseadapter,Notifydatasetchanged,在Android中,我编写了一个类 public class ImageAdapter extends BaseAdapter { private Context context; private Cursor imageCursor; public ImageAdapter(Context context, Cursor imageCursor) { this.context = context; this.imageCursor =
public class ImageAdapter extends BaseAdapter {
private Context context;
private Cursor imageCursor;
public ImageAdapter(Context context, Cursor imageCursor) {
this.context = context;
this.imageCursor = imageCursor;
}
}
在这段代码中,我想在调用notifyDataSetChanged()方法时更新imageCursor变量的值。
我怎么能做到 您可以重写notifyDatasetChanged()并在调用super.notifyDatasetChanged之前放置代码,也可以创建这样的自定义方法
public void updateNotifyDatasetChanged(Cursor newImageCursor){
this.imageCursor = newImageCursor;
notifyDatasetChanged();
}
哈哈,不用担心,有时候只是需要用另一双眼睛来看待一个问题。