Xutils 和 Okhttp调用notifyDataSetChanged区别

在Xutils中 可直接在onSuccess方法中调用 myAdapter.notifyDataSetChanged();通知适配器发生改变

okhttp中 不能在onResponse方法中直接调用

okHttpClient.newCall(request).enqueue(new okhttp3.Callback() {

    @Override

    public void onFailure(Call call, IOException e) {

        Log.e("test", e.getMessage());

    }

    @Override

    public void onResponse(Call call, Response response) throws IOException {

        Message msg = new Message();

        handler.sendMessage(msg);

    }

});

private Handler handler = new Handler() {

    public void handleMessage(Message msg) {

    myAdapter.notifyDataSetChanged();

    };

};

你可能感兴趣的:(Xutils 和 Okhttp调用notifyDataSetChanged区别)