Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在BaseAdapter中更新自定义变量?_Android_Baseadapter_Notifydatasetchanged - Fatal编程技术网

Android 如何在BaseAdapter中更新自定义变量?

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 =

在Android中,我编写了一个类

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();
}

哈哈,不用担心,有时候只是需要用另一双眼睛来看待一个问题。