【发布时间】:2018-09-08 01:24:12
【问题描述】:
我是使用 MVVM 的新手,通过搜索我发现 Retrofit 服务的实现和调用将在 ViewModel 中,但我的问题是我想获取 Retrofit Api 调用的响应并将其传递给 recyclerView。如果我在 ViewModel 中有任何视图,我该怎么做?请给点建议?
services.getData().enqueue(new Callback<Data>() {
@Override
public void onResponse(Call<Data> call, Response<Data> response) {
// the response contains an arrayList, that I want to pass it to recyclerView
}
@Override
public void onFailure(Call<Data> call, Throwable t) {
}
});
【问题讨论】: