我正在使用改造来呼叫数据。以下是我的情话
public class DataList {
@SerializedName("pariyojanaId")
@Expose
private Integer pariyojanaId;
@SerializedName("projectStatus")
@Expose
private String projectStatus;
@SerializedName("heading")
@Expose
private String heading;
@SerializedName("projectNumber")
@Expose
private Integer projectNumber;
@SerializedName("fieldTitle")
@Expose
private String fieldTitle;
@SerializedName("targetedGroup")
@Expose
private String targetedGroup;
//getter setter
}
以下是我的改造课程
pariyojanaInterfaces = ApiClient.getApiClient().create(PariyojanaInterface.class);
Call<DataList> call = pariyojanaInterfaces.getData(memberId);
Log.e("urll",call.request().toString());
call.enqueue(new Callback<DataList>() {
@Override
public void onResponse(Call<DataList> call, Response<DataList> response) {
datas = Collections.singletonList(response.body());
ItemListAdapter itemListAdapter = new ItemListAdapter(context, datas);
holder.rv.setLayoutManager(new LinearLayoutManager(context));
holder.rv.setAdapter(itemListAdapter);
}
@Override
public void onFailure(Call<DataList> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
正在设置我的适配器,但是设置的值为null。以下是我的适配器类的bindView持有人
public void onBindViewHolder(ListViewHolder holder, int position) {
datas = dataList.get(position);
//Log.e("datasss", datas + "");
holder.txtPariyojanaId.setText(String.valueOf(datas.getPariyojanaId()));
holder.txtProjectStatus.setText(String.valueOf(datas.getProjectStatus()));
holder.txtHeading.setText(String.valueOf(datas.getHeading()));
holder.txtFieldTitle.setText(datas.getFieldTitle());
holder.txtTargetedGroup.setText(datas.getTargetedGroup());
Log.e("datahead","" + datas.getHeading() );
}
当我打印日志时,正在打印的数据为空。我不认为我的pojo有任何问题,并且url中也有数据。有人可以帮我解决这个问题吗?我不知道为什么我会变空。